I am in a begginers Visual Basic class and have to find out how to navigate through records. In my program, I can navigate to the "next record" but I have no idea how to write the code to go to the "Previous Record." If anyone could help I would really appreciate it. Here's my code so far...
'This form allows the user to view the data in the text file.
Option Explicit
Private intAccountInfor mation As Integer
Private Sub cmdExit_click()
Unload Me
End Sub
Private Sub cmdNext_click()
Dim strRecord As String * 112
Dim strName As String * 30
Dim strAddress As String * 35
Dim strCity As String * 25
Dim strState As String * 2
Dim strZip As String * 5
Dim strAccount As String * 6
Dim strBalance As String * 7
Dim curBalance As Currency
Get #intAccountInfo rmation, , strRecord
If EOF(intAccountI nformation) Then
MsgBox "There are no more records in the file."
Else
strName = Mid(strRecord, 1, 30)
strAddress = Mid(strRecord, 31, 35)
strCity = Mid(strRecord, 66, 25)
strState = Mid(strRecord, 91, 2)
strZip = Mid(strRecord, 93, 5)
strAccount = Mid(strRecord, 97, 6)
strBalance = Mid(strRecord, 105, 7)
curBalance = CCur(strBalance ) / 100
lblBalanceData. Caption = Format(curBalan ce, "$0.00")
lblNameData.Cap tion = strName
lblAddressData. Caption = strAddress
lblCityData.Cap tion = strCity
lblStateData.Ca ption = strState
lblZipData.Capt ion = strZip
lblAccountData. Caption = strAccount
End If
End Sub
Private Sub cmdPrevious_Cli ck()
End Sub
Private Sub form_load()
Dim strAccountInfor mation As String
intAccountInfor mation = FreeFile
strAccountInfor mation = App.Path & "\OutPutFile.tx t"
Open strAccountInfor mation For Random Access Read As #intAccountInfo rmation Len = 112
End Sub
Private Sub form_unload(can cel As Integer)
Close #intAccountInfo rmation
End Sub
'This form allows the user to view the data in the text file.
Option Explicit
Private intAccountInfor mation As Integer
Private Sub cmdExit_click()
Unload Me
End Sub
Private Sub cmdNext_click()
Dim strRecord As String * 112
Dim strName As String * 30
Dim strAddress As String * 35
Dim strCity As String * 25
Dim strState As String * 2
Dim strZip As String * 5
Dim strAccount As String * 6
Dim strBalance As String * 7
Dim curBalance As Currency
Get #intAccountInfo rmation, , strRecord
If EOF(intAccountI nformation) Then
MsgBox "There are no more records in the file."
Else
strName = Mid(strRecord, 1, 30)
strAddress = Mid(strRecord, 31, 35)
strCity = Mid(strRecord, 66, 25)
strState = Mid(strRecord, 91, 2)
strZip = Mid(strRecord, 93, 5)
strAccount = Mid(strRecord, 97, 6)
strBalance = Mid(strRecord, 105, 7)
curBalance = CCur(strBalance ) / 100
lblBalanceData. Caption = Format(curBalan ce, "$0.00")
lblNameData.Cap tion = strName
lblAddressData. Caption = strAddress
lblCityData.Cap tion = strCity
lblStateData.Ca ption = strState
lblZipData.Capt ion = strZip
lblAccountData. Caption = strAccount
End If
End Sub
Private Sub cmdPrevious_Cli ck()
End Sub
Private Sub form_load()
Dim strAccountInfor mation As String
intAccountInfor mation = FreeFile
strAccountInfor mation = App.Path & "\OutPutFile.tx t"
Open strAccountInfor mation For Random Access Read As #intAccountInfo rmation Len = 112
End Sub
Private Sub form_unload(can cel As Integer)
Close #intAccountInfo rmation
End Sub
Comment