' Change this constant if you want the program's INI file
' to have a different name.

Const InitFile$ = "test.ini"

Declare Function GetPrivateProfileString Lib "Kernel" 
        (ByVal Section$, ByVal Entry$, ByVal Default$, 
         ByVal Buffer$, ByVal Size%, ByVal FileName$) As Integer

Declare Function WritePrivateProfileString Lib "Kernel" 
        (ByVal Section$, ByVal Entry$, ByVal Buffer$, 
         ByVal FileName$) As Integer

Sub Form_Load ()

' When the form is loaded, read size and position
' settings from the [forms] section of the program's INI file.

Dim Buffer As String * 10
Section$ = "forms"

Entry$ = "height"
i = GetPrivateProfileString(Section$, Entry$, "2000", Buffer,
	 Len(Buffer), InitFile$)
Height = Val(Buffer)

Entry$ = "width"
i = GetPrivateProfileString(Section$, Entry$, "2000", Buffer,
	 Len(Buffer), InitFile$)
Width = Val(Buffer)

Entry$ = "top"
i = GetPrivateProfileString(Section$, Entry$, "2000", Buffer,
	 Len(Buffer), InitFile$)
Top = Val(Buffer)

Entry$ = "left"
i = GetPrivateProfileString(Section$, Entry$, "2000", Buffer,
	 Len(Buffer), InitFile$)
Left = Val(Buffer)

End Sub

Sub Form_Unload (Cancel As Integer)

' When the form is unloaded, save its size and
' position to the [forms] section of the program's INI file.

Dim Buffer As String * 10
Section$ = "forms"

Buffer = Str$(Height)
Entry$ = "height"
i = WritePrivateProfileString(Section$, Entry$, Buffer, InitFile$)

Buffer = Str$(Width)
Entry$ = "width"
i = WritePrivateProfileString(Section$, Entry$, Buffer, InitFile$)

Buffer = Str$(Top)
Entry$ = "top"
i = WritePrivateProfileString(Section$, Entry$, Buffer, InitFile$)

Buffer = Str$(Left)
Entry$ = "left"
i = WritePrivateProfileString(Section$, Entry$, Buffer, InitFile$)

End Sub

Sub Command1_Click ()

Unload Form1
End

End Sub
