Dim num1 As
Double
Dim Op As String
Private Sub CmdDigit_Click(Index As Integer)
Txtnum1.Text = Txtnum1.Text & CmdDigit(Index).Caption
End Sub
Private Sub CmdOp_Click(Index As Integer)
num1 = Val(Txtnum1.Text)
Txtnum1.Text = ""
Op = CmdOp(Index).Caption
End Sub
Dim Op As String
Private Sub CmdDigit_Click(Index As Integer)
Txtnum1.Text = Txtnum1.Text & CmdDigit(Index).Caption
End Sub
Private Sub CmdOp_Click(Index As Integer)
num1 = Val(Txtnum1.Text)
Txtnum1.Text = ""
Op = CmdOp(Index).Caption
End Sub
Private Sub
CmdEqual_Click(Index As Integer)
Select Case Op
Case "+"
Txtnum1.Text = num1 + Val(Txtnum1.Text)
Case "-"
Txtnum1.Text = num1 - Val(Txtnum1.Text)
Case "*"
Txtnum1.Text = num1 * Val(Txtnum1.Text)
Case "/"
Txtnum1.Text = num1 / Val(Txtnum1.Text)
End Select
End Sub
Select Case Op
Case "+"
Txtnum1.Text = num1 + Val(Txtnum1.Text)
Case "-"
Txtnum1.Text = num1 - Val(Txtnum1.Text)
Case "*"
Txtnum1.Text = num1 * Val(Txtnum1.Text)
Case "/"
Txtnum1.Text = num1 / Val(Txtnum1.Text)
End Select
End Sub
Private Sub
CmdC_Click(Index As Integer)
Txtnum1.Text = "0"
End Sub
Txtnum1.Text = "0"
End Sub
Output
Note:- Please set some property of your control like caption
or id corresponding to your control