数字健text1.text=text "0"text1.text=text "1"……text "9"运算符text1=" "……text="/"是不是这样做?还有等于怎么做啊?
一个简易计算器:
在窗体上添加一个按钮组Command1(index值0至10,caption分别为1-9 ,0,和小数点. )按钮组command2(index值0至4,caption分别为+ - X /(加减乘除)和=),另加一个text1 以上控件可放在一个框架Frame1内
Option Explicit
Dim v As Boolean
Dim s As Integer
Dim x As Double
Dim y As Double
Private Sub Command1_Click(Index As Integer)
If Form1.Tag = "s" Then
If Index = 10 Then
Text1.Text = "0"
Else
Text1.Text = Command1(Index).Caption
End If
Form1.Tag = ""
Else
Text1.Text = Text1.Text & Command1(Index).Caption
End If
End Sub
Private Sub Command2_Click(Index As Integer)
Form1.Tag = "s"
If v Then
x = Val(Text1.Text)
v = Not v
Else
y = Val(Text1.Text)
Select Case s
Case 0
Text1.Text = x + y
Case 1
Text1.Text = x - y
Case 2
Text1.Text = x * y
Case 3
If y <> 0 Then
Text1.Text = x / y
Else
MsgBox ("不能以0为除数")
Text1.Text = x
v = False
End If
Case 4
y = 0
v = False
End Select
x = Val(Text1.Text)
End If
s = Index
End Sub
程序效果图:
来自:求助得到的回答看不明白你要解决的题目是什么