Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Revert to saved .txt data

Status
Not open for further replies.

icallig

Programmer
Jun 20, 2001
3
US
My app writes data to a text file from a user-input form. The first time the application runs, it creates the file. After that point, the file may be overwritten as needed. This part is working fine.

I have included a "Revert" button which should revert to the last saved data in the text file, after the data has been saved for the first time. This works great in the debugger, but not in a full .exe. The first time the app runs (and so creates the file), the revert does not work correctly. Once the app has been closed and reopened, the revert does work correctly.
Here's a bit of the code:

Private Sub bRevert_Click()
Retrieve
DisplayForm
End Sub

Public Sub Retrieve()
Open CTIfile For Append As 1
If LOF(1) = 0 Then
Err.Number = 1
End If
Close #1

'bring in configs, if existing
If Err.Number <= 0 Then
Open CTIfile For Input As #1

Input #1, Rout
Input #1, MaxSpeed
Input #1, MPH
Close #1
End If

End Sub

I'm fairly new to VB, so sorry if I'm missing the obvious. Thanks in advance for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top