VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Save checkbox"
   ClientHeight    =   615
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4095
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   615
   ScaleWidth      =   4095
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Delete 
      Caption         =   "Delete"
      Height          =   375
      Left            =   2640
      TabIndex        =   3
      Top             =   120
      Width           =   975
   End
   Begin VB.CommandButton Exit 
      Caption         =   "Exit"
      Height          =   375
      Left            =   1560
      TabIndex        =   2
      Top             =   120
      Width           =   975
   End
   Begin VB.CommandButton Save 
      Caption         =   "Save"
      Height          =   375
      Left            =   480
      TabIndex        =   1
      Top             =   120
      Width           =   975
   End
   Begin VB.CheckBox Check1 
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   255
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Delete_Click()
Dim CheckFileExist As String

CheckFileExist = Dir$("C:\chk.ini")
If CheckFileExist = "chk.ini" Then
    Kill ("C:\chk.ini")
    MsgBox "file deleted"
Else
    MsgBox "No file saved!"
End If

End Sub

Private Sub Exit_Click()
End
End Sub

Private Sub Form_Load()
Dim ff As Integer
Dim CheckFileExist As String
Dim BoxBool As Boolean

ff = FreeFile()

CheckFileExist = Dir$("C:\chk.ini")
If CheckFileExist = "chk.ini" Then
    Open "C:\chk.ini" For Input As #ff
    While Not EOF(ff)
        Input #ff, BoxBool
    Wend
    Close #ff
End If

If BoxBool = True Then
    Check1.Value = 1
End If

End Sub

Private Sub Save_Click()
Dim ff As Integer
Dim BoxBool As Boolean

ff = FreeFile()

If Check1.Value = 1 Then
    BoxBool = True
Else
    BoxBool = False
End If

Open "C:\chk.ini" For Output As #ff
Write #ff, BoxBool
Close #ff

MsgBox "Checkbox value " & BoxBool & " saved to file!"

End Sub
