独孤失败007 - 2005-7-2 17:43:00
代码:
Private Sub Command1_Click()
For Y = 1 To 9
m(Y) = 0
Next
For X = 0 To 8
Do
Randomize
i = Int(9 * Rnd())
Loop While m(i) = 1
Set m(i) = 1
n(X) = i
Next
Text1.Text = n(0) & n(1) & n(2) & n(3) & n(4) & n(5) & n(6) & n(7) & n(8)
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim n(0 To 8) As Integer '无重复的随机数组
Dim m(1 To 9) As Integer '标志
Dim X, Y As Integer
End Sub
编译总是报错 说函数未定义! 郁闷```
独孤失败007 - 2005-7-2 19:28:00
错在哪啊?
独孤失败007 - 2005-7-2 22:23:00
自己顶
独孤失败007 - 2005-7-2 23:30:00
郁闷 没人帮我~
独孤失败007 - 2005-7-3 10:35:00
DD
江湖游客 - 2005-7-4 23:38:00
不是函数没定义,而是数组未定义。你忽视了定义数组变量的全局性与区域性的区别,在Form_Load()事件加载后所定义的变量时效性已过。所以在执行按钮事件代码时,m(Y)会被视之为一个函数而不是你定义的数组变量了。
另外,数组赋值也会出现错误。因为你用Set m(i) = 1就变成集合赋值了。
头很大 - 2005-7-6 3:51:00
n(x)也一样,另外For Y = 1 To 9 ,Dim m(1 To 9) As Integer 溢出了,呵呵
© 2000 - 2024 Rising Corp. Ltd.