vb 用代码表示我的问题吧 计算器加

来源:百度知道 编辑:UC知道 时间:2024/05/21 04:33:08
例如 1+2时
点击1运行 红色语句
Public Sub bBt_Click(Index As Integer)

If nflag = "" Then
F001.text1.Text = Trim(Str(Val(F001.text1.Text) * 10 + Index)) Else
flag = nflag
nflag = ""
Select Case flag
Case "+"

F001.text1.Text = Trim(Index)

b = F001.text1.Text

a = a + b

Case "-"

F001.text1.Text = Trim(Index)

b = F001.text1.Text

Case "*"
F001.text1.Text = Trim(Index)

b = F001.text1.Text

Case "/"
F001.text1.Text = Trim(Index)

b = F001.text1.Text
End Select

F001.text1.Text = Index

End If
End Sub

点击加号

Public aa As Long
Public nn As Long
Dim zlb As Boolean
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Text1.Text = Val(Text1.Text) * 10 + Index
Case 10
Text1.Text = ""
Text1.SetFocus
Case 11
aa = Val(Text1.Text)
nn = 11
Text1.Text = "加"
Case 12
aa = Val(Text1.Text)
nn = 12
Text1.Text = "减"
Case 13
aa = Val(Text1.Text)
nn = 13
Text1.Text = "乘"
Case 14
aa = Val(Text1.Text)
nn = 14
Text1.Text = "除"
Case 15

If nn = 11 Then
Text1.Text = Val(Text1.Text) + aa
End If
If nn = 12 Then
Text1.Text = aa - Val(Text1.Text)
End If
If nn = 13 Then
Text1.Text = Val(Text1.Text) * aa
End If
If nn = 14 Then
Text1.Text = aa / Val(Text1.Text)
End If

End Select
End Sub
你看一下,这是个计算器代码.