vb 下标越界,怎么办
发布网友
发布时间:2024-10-24 07:04
我来回答
共1个回答
热心网友
时间:2024-10-24 20:30
改一下ReDim a(i) As Integer
Private Sub Command1_Click()
Dim i As Integer, y As String, z As String, n As Integer, m As Integer, j As Integer
i = 1
For i = 1 To 20
ReDim a(0 To i) As Integer
a(i) = Int(Rnd * 90) + 10
Next i
For j = 1 To 20
If a(j) Mod 2 = 0 Then
y = y & a(j)
n = n + 1
End If
If a(j) Mod 2 = 0 Then
z = z & a(j)
m = m + 1
End If
Next j
Print "这20个随机数中偶数有:"; "y"
Print "这20个随机数中奇数有:"; "x"
Print "偶数共"; "n"; "个"
Print "奇数共"; "m"; "个"
End Sub