源码如下:
Dim a, a1, a2, a3 As Long
Dim opration_type As Integer
Private Sub Command1_Click(Index As Integer)
For i = 0 To Me.Command1.Count - 1
       Me.Command1(i).Caption = i 'use circulation initialization buttons
       Next
       a = Me.Command1(Index).Caption + a * 10
       Text1.Text = a
End SubPrivate Sub Command2_Click()
a = 0
Text1.Text = a  'initialization text1&text2
Text2.Text = a
End SubPrivate Sub Command3_Click()
Unload Me
End SubPrivate Sub Command4_Click(Index As Integer)
opration_type = Index  'transmission value
a1 = Val(Text1.Text)
a = 0
Text1.Text = a
End SubPrivate Sub Command5_Click()
a2 = Val(Text1.Text)
Select Case opration_type 'juge the opration_type
    Case 0: a3 = a1 + a2
    Case 1: a3 = a1 - a2
    Case 2: a3 = a1 * a2
    Case 3: a3 = a1 / a2
End Select
Text2.Text = a3
End SubPrivate Sub Command7_Click()End Sub
只实现了基本运算,无出错提示.想实现小数操作.请各位指点.

解决方案 »

  1.   

    用keyup或者keydown事件,在计算器输出框默认设置小数点在最右边。
    当keycode=110或者190的时候
    建议控制在小键盘这边计算,用110(.)做为标志。设输出框中数值为I,没按它,,不用管。
    按了它,
    记录后面的输入内容J,最后输出框的数值就是I+J/10^N,这个N是按了小数点后,再按数字键的次数。
      

  2.   

    可以考虑用字符串,比如用format函数,有点麻烦
      

  3.   

    问题是很多的,我刚做计算器,成功了,代码很复杂,不知道怎么简化
        你的先定义个boolean 变量记录小数点出现及出现几次这个事件
                            然后不需要输入小数点的时候记得
                           Exit Sub
      

  4.   

    主要是自己慢慢想,计算器的功能还是蛮多的!记得别把自己搞糊涂了
         都是采用布尔变量boolean实现的!