Private Sub Command1_Click()
Text1.Text = Text1.Text & Command1.Caption
End Sub
Private Sub Command10_Click()
Text1.Text = Text1.Text + Command10.Caption
End Sub
Private Sub Command11_Click()
Text1.Text = ""
End Sub
Private Sub Command12_Click(), 等号
End Sub
Private Sub Command13_Click()
Text1.Text = Text1.Text + Command13.Caption
End Sub
Private Sub Command14_Click()
Text1.Text = Text1.Text + Command14.Caption
End Sub
Private Sub Command15_Click()
Text1.Text = Text1.Text + Command15.Caption
End Sub
Private Sub Command16_Click()
Text1.Text = Text1.Text + Command16.Caption
End Sub
Private Sub Command17_Click()
Text1.Text = Text1.Text + Command17.Caption
End Sub
Private Sub Command2_Click()
Text1.Text = Text1.Text + Command2.Caption
End Sub
Private Sub Command3_Click()
Text1.Text = Text1.Text + Command3.Caption
End Sub
Private Sub Command4_Click()
Text1.Text = Text1.Text + Command4.Caption
End Sub
Private Sub Command5_Click()
Text1.Text = Text1.Text + Command5.Caption
End Sub
Private Sub Command6_Click()
Text1.Text = Text1.Text + Command6.Caption
End Sub
Private Sub Command7_Click()
Text1.Text = Text1.Text + Command7.Caption
End Sub
Private Sub Command8_Click()
Text1.Text = Text1.Text + Command8.Caption
End Sub
Private Sub Command9_Click()
Text1.Text = Text1.Text + Command9.Caption
End Sub
好像在vb中不会运行呀,请高手说请楚点行吗?
Private Sub Command1_Click()
'在文本框 text1.text 中输入的格式需要是 X+Y 这中方式
Dim a As Double
Dim b As Double
a = Mid(Text1.Text, 1, InStr(Text1.Text, "+") - 1)
b = Mid(Text1.Text, InStr(Text1.Text, "+") + 1)
Text1.Text = a + b
End Sub
在加减乘除的按钮按下时,查看当前操作是不是加减乘除状态,是则调用等号功能,并对当前Text1的值保存到全局变量,对应操作也存到全局变量
其次,数字按钮按下时,首先要确定是不是加减乘除状态,是则更新当前值,清空Text1,把当前数字赋给Text1;不是则按照你现在的方式更改Text1
最后,等号功能,按照当前操作,拿全局变量当前值和Text1的值进行相应加减乘除