by Joeffel (1 Submission)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 16th December 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Calculator
API Declarations
Dim Num1 As Integer, Num2 As Integer
Dim operator As String
txt_input.text = txt_input.text + "1"
End Sub
*NOTE: Repeat code for the rest of operands.
Private Sub cmd_add_click()
operator = "+"
Num1 = Val(txt_input.text)
End Sub
*NOTE: Repeat code for the rest of operators. You can modify the operator indicator if you desire according to the mathematical operator to be used.
Private Sub cmd_calculate_click()
if operator = "+" Then
Num2 = Val(txt_input.text)
txt_input = Num1 + Num2
End If
if operator = "-"
Num2 = Val(txt_input.text)
txt_input = Num1 - Num2
End If
if operator = "/"
Num2 = Val(txt_input.text)
txt_input = Num1 / Num2
End If
if operator = "*"
Num2 = Val(txt_input.text)
txt_input = Num1 * Num2
End if
End Sub