这个VB单击第2个按钮错在哪里
OptionBase1PrivateSubCommand1_Click()Dima(4,5)Fori=1To4Forj=1To5a(i,j)=Int(9*Rnd)+1De...
Option Base 1
Private Sub Command1_Click()
Dim a(4, 5)
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(9 * Rnd) + 1
Debug.Print a(i, j);
Next
Debug.Print
Next
End Sub
Private Sub Command2_Click()
For j = 1 To 5
L(j) = 0
For i = 1 To 4
L(j) = L(j) + a(i, j)
Next
Text1 = Text1 & Str(L(j))
End Sub
' 这个VB单击第2个按钮错在哪里
二维数组按列求和 展开
Private Sub Command1_Click()
Dim a(4, 5)
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(9 * Rnd) + 1
Debug.Print a(i, j);
Next
Debug.Print
Next
End Sub
Private Sub Command2_Click()
For j = 1 To 5
L(j) = 0
For i = 1 To 4
L(j) = L(j) + a(i, j)
Next
Text1 = Text1 & Str(L(j))
End Sub
' 这个VB单击第2个按钮错在哪里
二维数组按列求和 展开
3个回答
2016-07-03
展开全部
两个错误:
1,数组应该是全局变量,不然在命令按钮2时取不到值。
2,少一个Next。
Dim a(4, 5)
Private Sub Command1_Click()
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(9 * Rnd) + 1
Debug.Print a(i, j);
Next
Debug.Print
Next
End Sub
Private Sub Command2_Click()
Dim L(5)
For j = 1 To 5
L(j) = 0
For i = 1 To 4
L(j) = L(j) + a(i, j)
Next
Text1 = Text1 & Str(L(j))
Next
End Sub
展开全部
你需要掌握的知识是:变量的作用域问题;
你在Private Sub Command1_Click()事件里声明的变量
Dim a(4, 5)
叫做私有变量,或者叫做局部变量,在该事件过程以外是无法识别到它的,改变方法:
Option Base 1
Dim a(4, 5)
Private Sub Command1_Click()
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(9 * Rnd) + 1
Debug.Print a(i, j);
Next
Debug.Print
Next
End Sub
Private Sub Command2_Click()
For j = 1 To 5
L(j) = 0
For i = 1 To 4
L(j) = L(j) + a(i, j)
Next
Text1 = Text1 & Str(L(j))
End Sub
你在Private Sub Command1_Click()事件里声明的变量
Dim a(4, 5)
叫做私有变量,或者叫做局部变量,在该事件过程以外是无法识别到它的,改变方法:
Option Base 1
Dim a(4, 5)
Private Sub Command1_Click()
For i = 1 To 4
For j = 1 To 5
a(i, j) = Int(9 * Rnd) + 1
Debug.Print a(i, j);
Next
Debug.Print
Next
End Sub
Private Sub Command2_Click()
For j = 1 To 5
L(j) = 0
For i = 1 To 4
L(j) = L(j) + a(i, j)
Next
Text1 = Text1 & Str(L(j))
End Sub
追问
还缺少一个NEXT
追答
你果然是只会要代码,到现在还是没有一点长进,还在原地踏步啊?
Private Sub Command2_Click()
For j = 1 To 5
L(j) = 0
For i = 1 To 4
L(j) = L(j) + a(i, j)
Next
Text1 = Text1 & Str(L(j))
Next
End Sub
把要来的代码,再去转给问你的人啊?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询