VB計算器代碼轉成PB的代碼,怎么實作,哪位高手指點一下.
=================================================================================================
這段VB計算器代碼的思路是這樣的,X,Y分別是第一個數和第二個數,判斷第一個數或第二個數則通過Z(加,減,乘,除)來實作
當按=號,通過case 判斷Z(加,減,乘,除)來執行加,減,乘,除
====================================================================================================
Dim x, y As String
Dim z As String
Dim l As String
Private Sub Command1_Click()
If z = "" Then
x = x & 0
Text1.Text = x
Else
y = y & 0
Text1.Text = y
End If
End Sub
Private Sub Command10_Click()
If z = "" Then
x = x & 7
Text1.Text = x
Else
y = y & 7
Text1.Text = y
End If
End Sub
Private Sub Command11_Click()
If z = "" Then
x = x & 8
Text1.Text = x
Else
y = y & 8
Text1.Text = y
End If
End Sub
Private Sub Command12_Click()
z = "*"
End Sub
Private Sub Command13_Click()
z = "/"
End Sub
Private Sub Command14_Click()
If z = "" Then
x = x & 9
Text1.Text = x
Else
y = y & 9
Text1.Text = y
End If
End Sub
Private Sub Command15_Click()
Select Case z
Case "+"
Text1.Text = Val(x) + Val(y)
Case "-"
Text1.Text = Val(x) - Val(y)
Case "*"
Text1.Text = Val(x) * Val(y)
Case "/"
Text1.Text = Val(x) / Val(y)
End Select
z = ""
l = "計算結果為"
Label1.Caption = l & Text1.Text
End Sub
Private Sub Command16_Click()
Text1.Text = ""
x = ""
y = ""
z = ""
End Sub
Private Sub Command2_Click()
If z = "" Then
x = x & 1
Text1.Text = x
Else
y = y & 1
Text1.Text = y
End If
End Sub
Private Sub Command3_Click()
If z = "" Then
x = x & 2
Text1.Text = x
Else
y = y & 2
Text1.Text = y
End If
End Sub
Private Sub Command4_Click()
z = "+"
End Sub
Private Sub Command5_Click()
z = "-"
End Sub
Private Sub Command6_Click()
If z = "" Then
x = x & 5
Text1.Text = x
Else
y = y & 5
Text1.Text = y
End If
End Sub
Private Sub Command7_Click()
If z = "" Then
x = x & 4
Text1.Text = x
Else
y = y & 4
Text1.Text = y
End If
End Sub
Private Sub Command8_Click()
If z = "" Then
x = x & 3
Text1.Text = x
Else
y = y & 3
Text1.Text = y
End If
End Sub
Private Sub Command9_Click()
If z = "" Then
x = x & 6
Text1.Text = x
Else
y = y & 6
Text1.Text = y
End If
End Sub
uj5u.com熱心網友回復:
這么簡單,你都明白就應該會了!Dim x, y As String
Dim z As String
Dim l As String
Private Sub Command1_Click()
If z = "" Then
x = x & 0
Text1.Text = x
Else
y = y & 0
Text1.Text = y
End If
End Sub
pb:
pb: string x,y,z,l
if z = '' then
x = x+0
st_1.text = x
else
y = y+0
st_1.text = y
end if
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/110654.html
標籤:腳本語言
上一篇:PB 中向服務器提交資料
下一篇:生成exe檔案后,連接資料庫錯誤
