Eof..

abckid24
12-13-2005, 09: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
Loop
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.

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

reboot
12-13-2005, 10:11 PM
..

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum