Re: [VB6 ] 計算機

看板Visual_Basic作者 (昨日之死)時間19年前 (2005/06/14 00:14), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串50/51 (看更多)
剛剛下午試著加入絕對值的計算功能 不知道哪裡做錯了 (不過迴圈那邊應該沒有錯,因為沒有用絕對值來跑的時候是OK的!!!) === 程式草稿: http://rapidshare.de/files/2358986/AAA.rar.html === Private Sub Command1_Click(Index As Integer) If Option1(0).Value Then Text1.Text = Text1.Text & Index Text5.Text = Text5.Text & Index ElseIf Option1(1).Value Then Text2.Text = Text2.Text & Index ElseIf Option1(2).Value Then Text3.Text = Text3.Text & Index ElseIf Option1(3).Value Then Text4.Text = Text4.Text & Index End If End Sub Private Sub Command10_Click() If Option1(0).Value Then Text1.Text = Text1.Text & Command10.Caption Text5.Text = Text5.Text & Command10.Caption ElseIf Option1(1).Value Then Text2.Text = Text2.Text & Command10.Caption ElseIf Option1(2).Value Then Text3.Text = Text3.Text & Command10.Caption ElseIf Option1(3).Value Then Text4.Text = Text4.Text & Command10.Caption End If 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() Label1.Caption = G(Text1.Text) End Sub Function G(s As String) Dim p As Integer, F As Integer, I As String, J As String Dim a As String, o As String, b As String, u As Integer Static c As Integer: c = c + 1 If c = 1 Then s = Replace(s, " ", "") o = "+": GoSub L20 If p > 0 Then GoSub L40: G = G(I) + G(J): GoTo L10 o = "-": GoSub L20 If p > 0 Then GoSub L40: G = G(I) - G(J): GoTo L10 o = "*": GoSub L20 If p > 0 Then GoSub L40: G = G(I) * G(J): GoTo L10 o = "/": GoSub L20 If p > 0 Then GoSub L40: G = G(I) / G(J): GoTo L10 o = "^": GoSub L20 If p > 0 Then GoSub L40 If I Like "-*" Then G = -G(Mid(I, 2)) ^ G(J) Else G = G(I) ^ G(J) End If GoTo L10 End If o = "Abs": GoSub L30 If p = 0 Then ElseIf p = 1 Then GoSub L50: G = G(I & J) ElseIf p > 1 Then a = Mid(s, p - 1, 1) If a = "+" Then GoSub L60: G = G(I & J) ElseIf a = "-" Then GoSub L70: G = G(I & J) Else GoSub L50: G = G(I & J) End If GoTo L10 End If G = Val(s) L10: c = c - 1: Exit Function L20: p = Len(s) + 1 u = 0 Do Do p = InStrRev(s, o, p - 1) If o = "^" Then Exit Do If p <= 1 Then F = 0 And u = u + 1 Else a = Mid(s, p - 1, 1) If a = "+" Or a = "-" Or a = "*" Or a = "/" Or a = "^" Then F = 1 And u = 0 Else F = 0 And u = u + 1 End If End If Loop While F = 1 If p <= 3 Then F = 0 And u = u + 1: Exit Do Do p = InStrRev(s, o, p - 3) If p <= 3 Then F = 0 And u = u + 1 Else b = Mid(s, p - 3, 3) If b = "Abs" Then F = 1 And u = 0 Else F = 0 And u = u + 1 End If End If Loop While F = 1 Loop While u < 2 If p = 1 Then p = 0 Return L30: p = InStrRev(s, o): Return L40: I = Left(s, p - 1): J = Mid(s, p + 1): Return L50: I = Left(s, p - 1): J = Abs(Val(Mid(s, s + 3))): Return L60: I = Left(s, p - 1): J = Abs(Val(Mid(s, s + 4))): Return L70: I = Left(s, p - 1): J = -Abs(Val(Mid(s, s + 4))): Return End Function Private Sub Command4_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Label1.Caption = "" End Sub Private Sub Command5_Click() End End Sub Private Sub Command6_Click() If Option1(0).Value Then Text1.Text = Text1.Text + Text2.Text Text5.Text = Text5.Text + "X" Else End If End Sub Private Sub Command7_Click() If Option1(0).Value Then Text1.Text = Text1.Text + Text3.Text Text5.Text = Text5.Text + "Y" Else End If End Sub Private Sub Command8_Click() If Option1(0).Value Then Text1.Text = Text1.Text + Text4.Text Text5.Text = Text5.Text + "Z" Else End If End Sub Private Sub Command9_Click() If Option1(0).Value Then If Len(Text1.Text) >= 1 Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) Text5.Text = Left(Text5.Text, Len(Text5.Text) - 1) Else End If ElseIf Option1(1).Value Then If Len(Text2.Text) >= 1 Then Text2.Text = Left(Text2.Text, Len(Text2.Text) - 1) Else End If ElseIf Option1(2).Value Then If Len(Text3.Text) >= 1 Then Text3.Text = Left(Text3.Text, Len(Text3.Text) - 1) Else End If ElseIf Option1(3).Value Then If Len(Text4.Text) >= 1 Then Text4.Text = Left(Text4.Text, Len(Text4.Text) - 1) Else End If End If End Sub -- 少年讀書,如隙中窺月; 中年讀書,如庭中望月; 老年讀書,如臺上玩月。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.162.72.67 ※ 編輯: TrueFeeling 來自: 218.162.72.67 (06/14 00:42)

210.58.156.43 06/14, , 1F
Mid(s, s + 3) ??????
210.58.156.43 06/14, 1F
文章代碼(AID): #12hR3APf (Visual_Basic)
討論串 (同標題文章)
文章代碼(AID): #12hR3APf (Visual_Basic)