只用一个文本框,也很简单啊利用控件数组 控件拖四个按所钮 一个文本框 并把COMMAND1 和COMMAND3 的 INDEX属性改为0 ,不然会出错 Dim sign, flag, a, b As Long '标记输入的数字 Private Sub Command1_Click(Index As Integer) '运算符 flag = Index If IsNumeric(Text1.Text) Then If sign = 0 Then a = CLng(Text1.Text) ElseIf sign = 1 Then MsgBox "错误操作" End If Else: MsgBox "输入错误": sign = 0 End If Text1.Text = "" sign = 1 End Sub Private Sub Command2_Click() '计算结果 If IsNumeric(Text1.Text) And sign = 1 Then b = CLng(Text1.Text) If flag = 0 Then Text1.Text = CStr(a + b) ElseIf flag = 1 Then Text1.Text = CStr(a - b) ElseIf flag = 2 Then Text1.Text = CStr(a * b) ElseIf flag = 3 Then Text1.Text = CStr(a / b) End If sign = 0 Else: MsgBox "错误操作,重新输入": sign = 0 End If End Sub Private Sub Command3_Click(Index As Integer) Text1.Text = Text1.Text & Index End Sub Private Sub Command4_Click() '清空结果 Text1.Text = "" sign = 0 End Sub Private Sub Form_Load() Form1.Width = 250 * 15 Form1.Height = 400 * 15 Form1.ScaleMode = 3 Text1.Left = 30 Text1.Text = "" Text1.Top = 20 Text1.Width = 150 Text1.Height = 30 '--------------------------------------- Command3(0).Caption = "0" Command3(0).Top = Text1.Top + 50 Command3(0).Left = 10 Command3(0).Width = 40 Command3(0).Height = 30 For i = 1 To 9 Load Command3(i) With Command3(i) Command3(i).Caption = Str(i) Command3(i).Left = Command3(i - 1).Left + 50 If i > 3 Then Command3(i).Left = Command3(0).Left + (Command3(0).Width + 10) * (i Mod 4) Command3(i).Top = Command3(0).Top + (Command3(0).Height + 10) * (i \ 4) End If Command3(i).Visible = True End With Next Command1(0).Left = 10 Command1(0).Top = Text1.Top + 200 Command1(0).Width = 40 Command1(0).Height = 30 For i = 1 To 3 Load Command1(i) With Command1(i) Command1(i).Visible = True Command1(i).Left = Command1(i - 1).Left + Command1(i - 1).Width + 10 End With Next Command1(0).Caption = "+" Command1(1).Caption = "-" Command1(2).Caption = "*" Command1(3).Caption = "/" Command2.Top = Text1.Top + 250 Command2.Visible = True Command2.Left = 100 Command2.Caption = "=" Command4.Caption = "清空结果" Command4.Top = Command2.Top Command4.Left = 20 End Sub