VB program to make a simple calculator


a simple calculator

Sample :


I can't show you complete code Directly so download full code from below .
Download the output to form design.


Private Sub cmddiv_Click()
Text1.Text = Text1.Text & "/"
End Sub


Private Sub cmdequal_Click()
Dim a, b As Double, bool As Boolean
Dim i As Integer, ch As String, op As String
    For i = 0 To Len(Text1.Text) - 1
        Text1.SelStart = i
        Text1.SelLength = 1
        ch = Text1.SelText
        If ch = "+" Or ch = "-" Or ch = "*" Or ch = "/" Or ch = "\" Or ch = "^" Or ch = "%" Then
            op = ch
            Debug.Print "op=" & op
            bool = True
           
        Else
            If bool Then
                b = (b * 10) + Val(ch)
            Else
                a = (a * 10) + Val(ch)
                Debug.Print a
            End If
    End If
    ch = ""
    Next
    Debug.Print "a=" & a & " b= " & b
    Select Case (op)
        Case "+": Text1.Text = a + b
        Case "-": Text1.Text = a - b
        Case "*": Text1.Text = a * b
        Case "/": Text1.Text = a / b
        Case "\": Text1.Text = a \ b
        Case "^": Text1.Text = a ^ b
        Case "%": Text1.Text = a Mod b
    End Select
    Text1.SelStart = Len(Text1.Text)
   
End Sub


Private Sub cmdintdiv_Click()
    Text1.Text = Text1.Text & "\"
End Sub


Private Sub cmdmod_Click()
    Text1.Text = Text1.Text & "%"
End Sub


Private Sub cmdmult_Click()
    Text1.Text = Text1.Text & "*"
End Sub


Private Sub cmdsub_Click()
Text1.Text = Text1.Text & "-"
End Sub


Private Sub command1_Click()
Text1.Text = Text1.Text & "^"
End Sub


Full Code :
Output(calculator.exe)

Full code(calculator.doc)

Full project(calculator.zip)

*Note Full project require Visual Basic 6.0