Visual_Basic 板


LINE

剛剛下午試著加入絕對值的計算功能 不知道哪裡做錯了 (不過迴圈那邊應該沒有錯,因為沒有用絕對值來跑的時候是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)
1F:推 fumizuki:Mid(s, s + 3) ?????? 210.58.156.43 06/14







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Boy-Girl站內搜尋

TOP