永发信息网

VB调用数组出项类型不匹配:缺少数组或用户定义类型

答案:2  悬赏:20  手机版
解决时间 2021-01-27 05:45
  • 提问者网友:黑米和小志
  • 2021-01-26 08:29
人实在比较笨。。看不出来问题。。
Dim a%()

Private Sub Form_Click()
Randomize
ReDim a(19)
For i = 0 To 19
a(i) = Int(Rnd * 101)
Picture1.Print a(i)
Next i
End Sub

Private Sub Command1_Click()
Dim b%, n%
n = 0
For i = 0 To 19
If a(i) > n Then
b = a(i): n = b
End If
Next i
Picture2.Print n
End Sub

Private Sub Command2_Click()
Dim b%, n%
n = 101
For i = 0 To 19
If a(i) < n Then
b = a(i): n = b
End If
Next i
Picture3.Print n
End Sub

Private Sub Command3_Click()
Dim sum%, av%, e%
e = UBound(a) + 1
For i = 0 To 19
sum = sum + a(i)
Next i
av = sum / e
Picture4.Print av
End Sub

Private Sub Command4_Click()
Dim s%(5), b%
For i = 0 To 19
Select Case a(i)
Case 0 To 59
s(1) = s(1) + 1
Case 60 To 69
s(2) = s(2) + 1
Case 70 To 79
s(3) = s(3) + 1
Case 80 To 89
s(4) = s(4) + 1
Case 90 To 100
s(5) = s(5) + 1
End Select
Next i
Picture5.Print "0-59分有" & s(1) & "人"
Picture5.Print "60-69分有" & s(2) & "人"
Picture5.Print "70-79分有" & s(3) & "人"
Picture5.Print "80-89分有" & s(4) & "人"
Picture5.Print "90-100分有" & s(5) & "人"
End Sub
Function paixu(a())
Dim i%, j%, t%
For i = LBound(a) To UBound(a) - 1
For j = LBound(a) To UBound(a) - 1 - i
If a(j) < a(j + 1) Then
t = a(j)
a(j) = a(j + 1)
a(j + 1) = t
End If
Nextj
Next i
End Function

Private Sub Command5_Click()
Call paixu(a())
For i = 0 To 19
Print a(i);
Next i
End Sub
最佳答案
  • 五星知识达人网友:往事隔山水
  • 2021-01-26 09:25
Dim a() ‘完全复制代码 运行即可

Private Sub Form_Click()
Randomize
ReDim a(19)
For i = 0 To 19
a(i) = Int(Rnd * 101)
Picture1.Print a(i)
Next i
End Sub

Private Sub Command1_Click()
Dim b%, n%
n = 0
For i = 0 To 19
If a(i) > n Then
b = a(i): n = b
End If
Next i
Picture2.Print n
End Sub

Private Sub Command2_Click()
Dim b%, n%
n = 101
For i = 0 To 19
If a(i) < n Then
b = a(i): n = b
End If
Next i
Picture3.Print n
End Sub

Private Sub Command3_Click()
Dim sum%, av%, e%
e = UBound(a) + 1
For i = 0 To 19
sum = sum + a(i)
Next i
av = sum / e
Picture4.Print av
End Sub

Private Sub Command4_Click()
Dim s%(5), b%
For i = 0 To 19
Select Case a(i)
Case 0 To 59
s(1) = s(1) + 1
Case 60 To 69
s(2) = s(2) + 1
Case 70 To 79
s(3) = s(3) + 1
Case 80 To 89
s(4) = s(4) + 1
Case 90 To 100
s(5) = s(5) + 1
End Select
Next i
Picture5.Print "0-59分有" & s(1) & "人"
Picture5.Print "60-69分有" & s(2) & "人"
Picture5.Print "70-79分有" & s(3) & "人"
Picture5.Print "80-89分有" & s(4) & "人"
Picture5.Print "90-100分有" & s(5) & "人"
End Sub
Function paixu(a())
Dim i%, j%, t%
For i = LBound(a) To UBound(a) - 1
For j = LBound(a) To UBound(a) - 1 - i
If a(j) < a(j + 1) Then
t = a(j)
a(j) = a(j + 1)
a(j + 1) = t
End If
Next j
Next i
End Function

Private Sub Command5_Click()
Call paixu(a)
For i = 0 To 19
Print a(i);
Next i
End Sub
全部回答
  • 1楼网友:渊鱼
  • 2021-01-26 10:12
我是来看评论的
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯