Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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 Folder riends.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 Folder riends.dat

Private Sub cmdRecieve_Click()

Dim phoneNumber As Integer

Dim firstName As String

Dim lastName As String

Open "C:UsersS3861452NDesktopSchool Folder riends.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