求助 运算溢出
Private Sub cmd_avg_Click()
Dim A(1 To 10) As Integer
Dim i As Integer, sum As Integer
Dim avg As Integer
Refresh_Scores
i = 0
Do While Adodc1.Recordset.EOF = True
i = i + 1
A(i) = Adodc1.Recordset( "考试成绩 ")
sum = sum + A(i)
Adodc1.Recordset.MoveNext
Loop
avg = Int(sum / i)
Text1.Text = Trim(Str(avg))
End Sub
运算后显示“avg = Int(sum / i)”溢出
[解决办法]
Dim i As Long, sum As Long
Dim avg As Long