关于VB程序的错误

来源:百度知道 编辑:UC知道 时间:2024/09/23 04:16:28
为什么总说“f(i) = a(1, r) * a(2, s) * a(3, t)”溢出
Option Explicit
Option Base 1
Dim a() As Integer, i As Integer, j As Integer

Private Sub Command1_Click()
ReDim a(3, 3)
For i = 1 To 3
For j = 1 To 3
a(i, j) = Int(Rnd * 90) + 10
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
End Sub

Private Sub Command2_Click()
Dim f(8) As Integer, b(8) As Integer, c(8) As Integer, d(8) As Integer
Dim r As Integer, s As Integer, t As Integer, x As Integer, max As Integer
i = 1
For r = 1 To 3
For s = 1 To 3
For t = 1 To 3
If r <> s And s <> t Then
f(i) = a(1, r) * a(2, s) * a(3, t)
b(i) = r: c(i) = s: d(i) = t
i = i + 1
End If
Next t
Next s
Next r
max = f(1)
For i = 2 To 8
If max < f(i) Then

Option Explicit
Option Base 1
Dim a() As Integer, i As Integer, j As Integer

Private Sub Command1_Click()
ReDim a(3, 3)
For i = 1 To 3
For j = 1 To 3
a(i, j) = Int(Rnd * 90) + 10
Picture1.Print a(i, j);
Next j
Picture1.Print
Next i
End Sub

Private Sub Command2_Click()
Dim f(27) As Double, b(27) As Integer, c(27) As Integer, d(27) As Integer
Dim r As Integer, s As Integer, t As Integer, x As Integer, max As Double
i = 1
For r = 1 To 3
For s = 1 To 3
For t = 1 To 3
If r <> s And s <> t Then
f(i) = CLng(a(1, r)) * CLng(a(2, s)) * CLng(a(3, t))
b(i) = r: c(i) = s: d(i) = t
i = i + 1
End If
Next t
Next s
Next r
max = f(1)
For i = 2 To 8
If max < f(i) Then
max = f(i)
x = i
End If
Next i
Text1 = "a(1,b(x))" & "=" & a(1, b(x)) & " " & "a(2,c(x))" & &quo