作者TrueFeeling (昨日之死)
看板Visual_Basic
标题Re: [VB6 ] 计算机
时间Sat Jun 11 20:42:42 2005
续上次做到一半的计算机:
在
Stop之前都可以正常运作
之後是因为宣告二维阵列出问题吗
出现了错误消息:
---------------------
Run-time error'9'
Script out of range
---------------------
++++
程式草稿:
http://0rz.net/2d0qK
++++
Dim A() As Double
Dim B() As String
Dim GS() As Double
Dim C()
Dim D()
Dim Accumulation()
Dim GA() As Double
Dim X, Y, Z
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Index
Text5.Text = Text5.Text & Index
End Sub
Private Sub Command2_Click(Index As Integer)
Text1.Text = Text1.Text & Command2(Index).Caption
Text5.Text = Text5.Text & Command2(Index).Caption
End Sub
Private Sub Command3_Click()
X = Val(Text2.Text)
Y = Val(Text3.Text)
Z = Val(Text4.Text)
H = Text1.Text
N = 0
Do
ReDim Preserve A(N)
ReDim Preserve B(N)
O = InStr(1, H, "+")
P = InStr(1, H, "-")
If O > 0 And P > 0 Then
If O < P Then
A(N) = O
Else
A(N) = P
End If
ElseIf O > 0 Then
A(N) = O
Else
A(N) = P
End If
If A(N) = 0 Then B(N) = H: Exit Do
B(N) = Left(H, (A(N) - 1))
H = Mid(H, A(N) + 1)
N = N + 1
Loop
Stop
For I = 1 To N
Do
ReDim Preserve C(I, M)
ReDim Preserve D(I, M)
Q = InStr(1, B(I), "*")
R = InStr(1, B(I), "/")
If Q > 0 And R > 0 Then
If Q < R Then
C(I, M) = Q
Else
C(I, M) = R
End If
ElseIf Q > 0 Then
C(I, M) = Q
Else
C(I, M) = R
End If
If C(I, M) = 0 Then D(I, M) = B(I): Exit Do
D(I, M) = Left(B(I), (C(I, M) - 1))
B(I) = Mid(B(I), C(I, M) + 1)
M = M + 1
Loop
Next I
Stop
ReDim Preserve GA(I, J)
For I = 0 To N
For J = 0 To M
GA(I, J) = Val(D(I, J))
Next J
Next I
For I = 0 To N
For J = 0 To (N - 1)
C(I, J + 1) = C(I, J + 1) + C(I, J)
If Mid(B(I), C(I, J), 1) = "*" Then
GA(I, J + 1) = Val(GA(I, J + 1))
Else
GA(I, J + 1) = 1 / Val(GA(I, J + 1))
End If
Next J
Next I
Accumulation(I) = 1
For I = 0 To N
For J = 0 To M
Accumulation(I) = Accumulation(I) * GA(I, M)
Next J
Next I
H = Text1.Text
ReDim Preserve GS(N)
For I = 0 To N
GS(I) = Val(Accumulation(I))
Next I
For I = 0 To (N - 1)
A(I + 1) = A(I + 1) + A(I)
If Mid(H, A(I), 1) = "+" Then
GS(I + 1) = Val(GS(I + 1))
Else
GS(I + 1) = -Val(GS(I + 1))
End If
Next I
Sum = 0
For I = 0 To N
Sum = Sum + GS(I)
Next I
Label1.Caption = Sum
End Sub
Private Sub Command4_Click()
Text1.Text = ""
Text5.Text = ""
Label1.Caption = ""
End Sub
Private Sub Command5_Click()
End
End Sub
Private Sub Command6_Click()
Text1.Text = Text1.Text + Text2.Text
Text5.Text = Text5.Text + "X"
End Sub
Private Sub Command7_Click()
Text1.Text = Text1.Text + Text3.Text
Text5.Text = Text5.Text + "Y"
End Sub
Private Sub Command8_Click()
Text1.Text = Text1.Text + Text4.Text
Text5.Text = Text5.Text + "Z"
End Sub
Private Sub Command9_Click()
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
Text5.Text = Left(Text5.Text, Len(Text5.Text) - 1)
End Sub
--
少年读书,如隙中窥月;
中年读书,如庭中望月;
老年读书,如台上玩月。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.141.159.236
※ 编辑: TrueFeeling 来自: 220.141.159.236 (06/11 20:43)
※ 编辑: TrueFeeling 来自: 220.141.159.236 (06/11 20:45)
※ 编辑: TrueFeeling 来自: 220.141.159.236 (06/11 20:48)
※ 编辑: TrueFeeling 来自: 220.141.159.236 (06/11 20:48)
※ 编辑: TrueFeeling 来自: 220.141.159.236 (06/11 20:55)
1F:推 fumizuki:说过了,多维阵列,只有最後一个上限可以变更 210.58.156.43 06/11
2F:推 fumizuki:前面的上限不管变大变小都会错误 210.58.156.43 06/11
3F:→ fumizuki:这是没有办法的 210.58.156.43 06/11