Q: Need Help! with Do Loop
The following code is part of an assignment that I am trying to complete by
Thursday. It is supposed to go through each of the records one by one and
stop when it gets to the last record. Having difficulty figuring out how
the Do function works to stop the program on the last record.
The following code is supposed to return the data for each record
in my file, when I press the Read BUTTON. It only returns the last
record and no other. Probably the placement of my do statement, but
I can't seem to get it to work.
Note: the file is opened by another command button.
-------------------------------------------------------------------
Private Sub cmdRead_Click()
Dim intNumericAverage As Integer
Dim strGrade As String
Dim intCounter As String
Do While Not EOF(intFileNum)
Input #intFileNum, strLastName, strFirstName, intEnglish, intFrench,
intGeography, intChemistry
intNumericAverage = (intEnglish + intFrench + intGeography + intChemistry) / 4
If intNumericAverage <= 54 Then
strGrade = "Fail"
ElseIf intNumericAverage <= 69 Then
strGrade = "Pass"
ElseIf intNumericAverage <= 84 Then
strGrade = "Good"
ElseIf intNumericAverage >= 85 Then
strGrade = "Excellent"
End If
txtLastName.Text = strLastName
txtFirstName.Text = strFirstName
txtEnglish.Text = CStr(intEnglish) & " %"
txtFrench.Text = CStr(intFrench) & " %"
txtGeography.Text = CStr(intGeography) & " %"
txtChemistry.Text = CStr(intChemistry) & " %"
lblnumericaverage.Caption = CStr(intNumericAverage) & " %"
lblGrade.Caption = strGrade
Loop
Close #intFileNum
End Sub
---------------------------------------------------
Bob Knight bknight@interlog.com
A: Get the file Grades.zip (28 Kb).
Return