Trying to create a form that allows a user to view all records in the friends.da
ID: 3572034 • Letter: T
Question
Trying to create a form that allows a user to view all records in the friends.dat file. Populate a list box on the form with the phone number and names of the friends. I cannot get this code to execute. Says it cant find the file or Input past end of file. Any help would be appreciated.
Private Sub cmdRecieve_Click()
Dim phoneNumber As Integer
Dim firstName As String
Dim lastName As String
Open "C:UsersS3861452NDesktopSchool Folderriends.dat"
For Input As #1 Input #1, phoneNumber, firstName, lastName
Do Until EOF(1) Input #1, phoneNumber, firstName, lastName
List0.AddItem "Question Number: " & phoneNumber & firstName
Loop
End Sub
Explanation / Answer
'' Make sure the file students.dat file is kept in this location: C:UsersS3861452NDesktopSchool Folderriends.dat
Private Sub cmdRecieve_Click()
Dim phoneNumber As Integer
Dim firstName As String
Dim lastName As String
Open "C:UsersS3861452NDesktopSchool Folderriends.dat" For Input As #1
'' Removed line Input #1, phoneNumber, firstName, lastName, should be called only EOF not reached. Incase of blank file it will fail the program.
Do Until EOF(#1)
Input #1, phoneNumber, firstName, lastName
List0.AddItem "Question Number: " & phoneNumber & firstName
Loop
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.