Geodesic_D
10-12-2007, 02:22 AM
Before I implement a save/load feature into one of my other applications, I created a new program to test it. I put some textboxes, buttons and a couple of checkboxes on the form, and then entered text and used the checkboxes to disable/enable the buttons. Then I pressed my save key. No problems.
The code I used to save was this.
Dim hFile As Long
Dim sFilename As String
sFilename = CurDir + "\savedata.txt"
hFile = FreeFile
Open sFilename For Output As #hFile
Print #hFile, txtItemOne.Text
Print #hFile, txtItemTwo.Text
Print #hFile, txtItemThree.Text
Print #hFile, Command1.Enabled
Print #hFile, Command2.Enabled
Print #hFile, Check1.Value
Print #hFile, Check2.Value
Close #hFile
MsgBox "Data Saved. A file called 'savedata.txt' was created.", vbInformation Or vbOKOnly, "Save Data"
I quit the application, restarted it and pressed the load button. Everything was put into one textbox. That is to say, the data I entered into the textboxes didn't appear where it should have and my checkboxes and buttons weren't checked/disabled and vice versa.
The code I use to load is this:
Dim hFile As Long
Dim sFilename As String
sFilename = CurDir + "\savedata.txt"
hFile = FreeFile
Open sFilename For Input As #hFile
txtItemOne.Text = Input$(LOF(hFile), hFile)
txtItemTwo.Text = Input$(LOF(hFile), hFile)
txtItemThree.Text = Input$(LOF(hFile), hFile)
Command1.Enabled = Input$(LOF(hFile), hFile)
Command2.Enabled = Input$(LOF(hFile), hFile)
Check1.Enabled = Input$(LOF(hFile), hFile)
Check2.Enabled = Input$(LOF(hFile), hFile)
Close #hFile
What am I doing wrong? I followed the instructions on the online tutorial exactly.
The code I used to save was this.
Dim hFile As Long
Dim sFilename As String
sFilename = CurDir + "\savedata.txt"
hFile = FreeFile
Open sFilename For Output As #hFile
Print #hFile, txtItemOne.Text
Print #hFile, txtItemTwo.Text
Print #hFile, txtItemThree.Text
Print #hFile, Command1.Enabled
Print #hFile, Command2.Enabled
Print #hFile, Check1.Value
Print #hFile, Check2.Value
Close #hFile
MsgBox "Data Saved. A file called 'savedata.txt' was created.", vbInformation Or vbOKOnly, "Save Data"
I quit the application, restarted it and pressed the load button. Everything was put into one textbox. That is to say, the data I entered into the textboxes didn't appear where it should have and my checkboxes and buttons weren't checked/disabled and vice versa.
The code I use to load is this:
Dim hFile As Long
Dim sFilename As String
sFilename = CurDir + "\savedata.txt"
hFile = FreeFile
Open sFilename For Input As #hFile
txtItemOne.Text = Input$(LOF(hFile), hFile)
txtItemTwo.Text = Input$(LOF(hFile), hFile)
txtItemThree.Text = Input$(LOF(hFile), hFile)
Command1.Enabled = Input$(LOF(hFile), hFile)
Command2.Enabled = Input$(LOF(hFile), hFile)
Check1.Enabled = Input$(LOF(hFile), hFile)
Check2.Enabled = Input$(LOF(hFile), hFile)
Close #hFile
What am I doing wrong? I followed the instructions on the online tutorial exactly.