VB 10个数,去一个最高分最低分,求平均分,为什么总出现未找到数据成员和方法

来源:百度知道 编辑:UC知道 时间:2024/05/13 13:54:16
Private Sub Command1_Click()

'定义变量,数组
Dim Max As Single
Dim Min As Single
Dim aryScores(10) As Single
Dim Last As Single
Dim i As Integer
'数组定义初始值
aryScores(0) = txt1.Text
aryScores(1) = txt2.Text
aryScores(2) = txt3.Text
aryScores(3) = txt4.Text
aryScores(4) = txt5.Text
aryScores(5) = txt6.Text
aryScores(6) = txt7.Text
aryScores(7) = txt8.Text
aryScores(8) = txt9.Text
aryScores(9) = txt10.Text
'查找最大值

Max = aryScores(0)
For i = 1 To 9
If aryScores(i) > Max Then
Max = aryScores(i)
End If
Next

'查找最小值
Min = aryScores(0)
For i = 1 To 9
If aryScores(i) < Min Then
Min = aryScores(i)
End If
Next

'求最后得分
For i =

你要确定txt1到txt10以及txtnum的控件都存在,名字是不是有错.

还有出错是光标是停在哪里?

出错是光标是停在哪里????

你的程序是对的。 在运行时,10个TextBox中都要有值。

不太明白你的问题的意思。

“数组定义初始值”出现问题了,
aryScores(0) = txt1.Text
应该写成Text1.text,其余的都是那么改。

txtnum.Text的值不明确。
只要以上有的控件都加上了,就不会出现“424”的现象了。。。

Dim aryScores(10) As Single 这句。
你改成
dim aryscores() as single试下

控件只要都有,就不会有错,程序没问题.