12-13-2005, 08:05 PM
Hey. Here's my code:

Option Explicit

Private Sub CommandButton1_Click()
Dim gradeCounter As Integer
Dim testGrade As Integer
Dim sumOfGrades As Integer
Dim averageGrade As Integer

Do While Not EOF(1)
gradeCounter = gradeCounter + 1
Open "C:\studentGrades.dat" For Input As #1
Input #1, testGrade
Close #1
sumOfGrades = sumOfGrades + testGrade
averageGrade = sumOfGrades / gradeCounter

MsgBox "Your Average Grade Is " & averageGrade

End Sub

Now, I get an error form the "Do While Not EOF(1)" line. It says run-time error "52." Bad file name or number.

Does anyone know what the problem is? Thanks for the help.

12-13-2005, 08:22 PM
you need to open the file before beginning the loop

12-13-2005, 09:11 PM

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum