求VB大神!这个5*5数组.求主对角线n个元素之积!为什么我输入3的时候!就溢出了呢?怎么改才对?
OptionBase1DimA()AsInteger,i,j,n,sAsIntegerPrivateSubCommand1_Click()ReDimA(5,5)AsInt...
Option Base 1
Dim A() As Integer, i, j, n, s As Integer
Private Sub Command1_Click()
ReDim A(5, 5) As Integer
For i = 1 To 5
For j = 1 To 5
A(i, j) = Int(Rnd * 90) + 10
Text1 = Text1 & A(i, j) & " "
Next j
Text1 = Text1 & vbCrLf
Next i
End Sub
Private Sub Command2_Click()
n = Text2.Text
s = 1
For i = 1 To n
s = s * A(i, i)
Next i
Text3 = s
End Sub 展开
Dim A() As Integer, i, j, n, s As Integer
Private Sub Command1_Click()
ReDim A(5, 5) As Integer
For i = 1 To 5
For j = 1 To 5
A(i, j) = Int(Rnd * 90) + 10
Text1 = Text1 & A(i, j) & " "
Next j
Text1 = Text1 & vbCrLf
Next i
End Sub
Private Sub Command2_Click()
n = Text2.Text
s = 1
For i = 1 To n
s = s * A(i, i)
Next i
Text3 = s
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询