dim int1 as integer
dim int2 as integer
int1=cint(text1.text)
int2=cint(text2.text)
debug.print int1+int2

解决方案 »

  1.   

    command1.caption="+" command2.caption="="****************when useman click text1insert number
    and click+***************
    dim int1,int2
    int1=cdbl(text1.text)
    text1.text=""
    *************useman insert number2 and click=
    **********int2=cdbl(text1.text)
    print int1+int2*************
      

  2.   

    Private Sub Form_Load()
    a = CLng(InputBox("第一个数"))
    b = CLng(InputBox("第二个数"))
    MsgBox a + b, , "和"
    End Sub
      

  3.   

    上面的程序:
    Two Text:Text1、Text2
    One Command:Command1command1.caption="+" command2.caption="="****************when useman click text1insert number
    and click+***************
    dim int1,int2 as Double
    int1=Val(text1.text)
    text1.text=""
    *************useman insert number2 and click=
    **********int2=Val(text2.text)
    Debug.print int1+int2*************
      

  4.   

    '看下面的代码,用控件数组,这是一个简易计算器
    Dim num1, num2, sum As Single
    Dim act As Integer
    Private Sub Command1_Click(Index As Integer)
    Select Case Index
    Case 0
        If Text1.Text = "" Then
            Text1.Text = "1"
        Else
            Text1.Text = Text1.Text + "1"
        End If
    Case 1
        If Text1.Text = "" Then
            Text1.Text = "2"
        Else
            Text1.Text = Text1.Text + "2"
        End If
    Case 2
        If Text1.Text = "" Then
            Text1.Text = "3"
        Else
            Text1.Text = Text1.Text + "3"
        End If
    Case 3
      If Text1.Text = "" Then
          Text1.Text = "4"
      Else
          Text1.Text = Text1.Text + "4"
      End If
    Case 4
        If Text1.Text = "" Then
            Text1.Text = "5"
        Else
            Text1.Text = Text1.Text + "5"
        End If
    Case 5
        If Text1.Text = "" Then
            Text1.Text = "6"
        Else
            Text1.Text = Text1.Text + "6"
        End If
    Case 6
        If Text1.Text = "" Then
            Text1.Text = "7"
        Else
            Text1.Text = Text1.Text + "7"
        End If
    Case 7
        If Text1.Text = "" Then
            Text1.Text = "8"
        Else
            Text1.Text = Text1.Text + "8"
        End If
    Case 8
        If Text1.Text = "" Then
            Text1.Text = "9"
        Else
            Text1.Text = Text1.Text + "9"
        End If
    Case 9
        If Text1.Text = "" Then
            Text1.Text = "0"
        Else
            Text1.Text = Text1.Text + "0"
        End If
    Case 10
        If Text1.Text = "" Then
            Text1.Text = "."
        Else
            Text1.Text = Text1.Text + "."
        End If
    Case 11
         num1 = CDbl(Text1.Text)
         Text1.Text = ""
         act = 1
    Case 12
         num1 = CDbl(Text1.Text)
         Text1.Text = ""
         act = 2
    Case 13
         num1 = CDbl(Text1.Text)
         Text1.Text = ""
         act = 3
    Case 14
         num1 = CDbl(Text1.Text)
         Text1.Text = ""
         act = 4
    Case 15
        num1 = CDbl(Text1.Text)
        Text1.Text = ""
        act = 5
    Case 16
        Text1.Text = ""
        num1 = 0: num2 = 0: sum = 0
    Case 17
         num2 = CDbl(Text1.Text)
         If act = 1 Then
            Text1.Text = num1 + num2
         End If
         If act = 2 Then
            Text1.Text = num1 - num2
         End If
         If act = 3 Then
            Text1.Text = num1 * num2
         End If
         If act = 4 Then
            Text1.Text = num1 / num2
         End If
         If act = 5 Then
            Text1.Text = num1 Mod num2
         End If
         If act = 6 Then
            Text1.Text = num1 ^ num2
         End If
         'Select Case act
         'Case 1
         '   sum = num1 + num2 '求和
         '   Text1.Text = sum
         'case 2
         '   sum = num1 - num2 '
         '   Text1.Text = sum
         'Case 3
         '   sum = num1 * num2
         '   Text1.Text = sum
         'Case 4
         '   sum = num1 / num2
         '   Text1.Text = sum
        'Case 5
         '   sum = num1 Mod num2
         '   Text1.Text = sum
        'End Select
    Case 18
        Unload Me
    Case 19
        Text1.Text = "0" + CStr(1 / CDbl(Text1.Text))
    Case 20
        Text1.Text = (CDbl(Text1.Text)) ^ (1 / 2)
    Case 21
        num1 = CDbl(Text1.Text)
        act = 6
        Text1.Text = ""
    End Select
    End Sub