我再用if的方式來進行字串的轉換但再轉換時卻出現只有第一行是正確的不知道為什麼以下我的程式碼及測試結果
Private Sub Command1_Click()
a = Text1.Text
aa = Split(a, " ")
If aa(0) = "org" And aa(1) <> "not" Then
bb = Replace(a, "org", "ld")
ElseIf aa(0) = "org" And aa(1) = "not" Then
bb = "ldi " & aa(2)
ElseIf aa(0) = "ld" And aa(1) <> "not" Then
bb = a
ElseIf aa(0) & aa(1) = "ldnot" Then
bb = "ldi " & aa(2)
ElseIf aa(0) = "and" And aa(1) <> "not" Then
bb = a
ElseIf aa(0) & aa(1) = "andnot" Then
bb = "ani " & aa(2)
Else
bb = a
End If
Text2.Text = bb
End Sub
測試的字串
org x0
org not x0
ld x0
ld not x0
and x0
and not x0
得出來的結果
ld x0
ld not x0
ld x0
ld not x0
and x0
and not x0
正確結果應該是
ld x0
ldi x0
ld x0
ldi x0
and x0
ani x0
麻煩指證指證我的錯誤之處
創作者介紹
創作者 vbqa 的頭像
vbqa

小吳 VBQA 程式設計討論

vbqa 發表在 痞客邦 留言(5) 人氣()