vb下标越界 请大家帮一下啊,老说下标越界。 Option Explicit Option Base 1 Private Sub Command1_Click(
OptionExplicitOptionBase1PrivateSubCommand1_Click()DimX(20)AsIntegerDimY(10To60)AsInt...
Option Explicit
Option Base 1
Private Sub Command1_Click()
Dim X(20) As Integer
Dim Y(10 To 60) As Integer
Dim i As Integer, j As Integer
Dim st As String
Randomize
For i = 1 To 20
X(i) = Int(Rnd * 51) + 10
Text1 = Text1 & Str(X(i)) & " "
If i Mod 10 = 0 Then Text1 = Text1 & vbCrLf
Y(X(i)) = 1
Next i
For i = 1 To 19
For j = i + 1 To 20
If X(i) = X(j) Then
X(j) = 0
Y(X(i)) = Y(X(i)) + 1
End If
Next j
Next i
For i = 1 To 20
If X(i) <> 0 Then
st = X(i) & "出现的次数:" & Str(Y(X(i))) & "次"
List1.AddItem st
End If
Next i
End Sub 展开
Option Base 1
Private Sub Command1_Click()
Dim X(20) As Integer
Dim Y(10 To 60) As Integer
Dim i As Integer, j As Integer
Dim st As String
Randomize
For i = 1 To 20
X(i) = Int(Rnd * 51) + 10
Text1 = Text1 & Str(X(i)) & " "
If i Mod 10 = 0 Then Text1 = Text1 & vbCrLf
Y(X(i)) = 1
Next i
For i = 1 To 19
For j = i + 1 To 20
If X(i) = X(j) Then
X(j) = 0
Y(X(i)) = Y(X(i)) + 1
End If
Next j
Next i
For i = 1 To 20
If X(i) <> 0 Then
st = X(i) & "出现的次数:" & Str(Y(X(i))) & "次"
List1.AddItem st
End If
Next i
End Sub 展开
3个回答
展开全部
Option Base 1 强制数组下标为1,
Dim Y(10 To 60) As Integer 你这句话把下标设为10,与上面的强制发生冲突.
把Option Base 1 这句删除
Dim Y(10 To 60) As Integer 你这句话把下标设为10,与上面的强制发生冲突.
把Option Base 1 这句删除
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Base 1 强制数组下标为1,
Dim Y(10 To 60) As Integer 你这句话把下标设为10,与上面的强制发生冲突.
把Option Base 1 这句删除
Dim Y(10 To 60) As Integer 你这句话把下标设为10,与上面的强制发生冲突.
把Option Base 1 这句删除
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数组下标是从0开始的.也就是说
X(20)最小下标0最大19
For i = 0 To 19
X(i) =...
Next i
X(20)最小下标0最大19
For i = 0 To 19
X(i) =...
Next i
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询