|
-
April 26th, 2006, 08:42 AM
#1
Inadvertent looping!
I'm a beginning student. Can someone tell me why this is looping each name for 3 rows in a list box? The file it's reading from is at the bottom.
Thanks
'DECLARE VARIABLES
Dim names(5) As String
Dim SCORES(5, 2) As Integer
Dim row, col As Integer
Dim ave(5) As Double
Dim grade(5) As String
Dim sum As Integer
Dim tstave As Integer
Private Sub CALC_Click()
lstdisplay.AddItem ("NAME - SCORES - AVERAGE - GRADE")
'OPEN FILE
Open "F:\DATAIN3.TXT" For Input As #1
Open "F:\DATAOUT3.TXT" For Output As #2
'GET DATA
For row = 0 To 5
Input #1, names(row)
sum = 0
For col = 0 To 2
Input #1, SCORES(row, col)
Next 'ROW
Next 'COL
For row = 0 To 5
sum = 0
For col = 0 To 2
'CALCULATE SUM OF SCORES
sum = sum + SCORES(row, col)
'CALCULATE AVERAGE OF SCORES
ave(row) = Math.Round((sum / 3), 2)
'CALCULATE LETTER GRADE
If ave(row) > 90 <= 100 Then grade(col) = "A" Else
If ave(row) > 80 < 90 Then grade(col) = "B" Else
If ave(row) > 70 < 80 Then grade(col) = "C" Else
If ave(row) > 60 < 70 Then grade(col) = "D" Else
If ave(row) < 60 Then grade(col) = "F"
'DISPLAY RESULTS
lstdisplay.AddItem (names(row) & " " & SCORES(row, col) & " " & ave(row) & " " & grade(row))
Print #2, names(row), SCORES(row, col)
Next 'ROW
Next 'COL
End Sub
Private Sub Command2_Click()
lstdisplay.Clear
End Sub
Private Sub EXIT_Click()
End
End Sub
datain3.txt:
ART
86
77
98
MARY
67
91
74
JILL
87
77
82
MARK
96
89
91
SAM
65
59
52
CAROL
89
85
71
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|