Dim score(5) As Integer, i As Integer, j As Integeraver = 0For i = 1 To 5 score(i) = Val(InputBox("請輸入成績")) aver = aver + score(i)Next iaver = aver / 5Text1.Text = averFor i = 1 To 5 If score(i) > 60 Then i = i + 1 Text2.Text = i j = 5 - i Text3.Text = j End IfNext i我的問題是,此題是用輸入框來完成數(shù)據(jù)的輸入,我想通過text的keypree事件來控制 該怎么樣寫出代碼,希望能注解一下..... 謝謝.............

熱心網(wǎng)友

你的變量aver未定義.數(shù)據(jù)的輸入由text的keypree事件來控制,代碼如下:Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 And Text1"" Then Text2.SetFocus End IfEnd Sub供參考,注意TEXT1的TabIndex設(shè)為0.