Showing posts with label Microsoft Visual Basic. Show all posts
Showing posts with label Microsoft Visual Basic. Show all posts

Simple Calculator Program using Microsoft Visual Basic

Here is the output of our simple calculator:


Here's the code:

Dim a, b, r As Integer
Dim opr As String

Private Sub add_Click()
a = Val(Text.Text)
opr = "+"
Text.Text = ""
End Sub

Private Sub clear_Click()
Me.Text.Text = " "

End Sub

Private Sub divide_Click()
a = Val(Text.Text)
opr = "/"
Text.Text = ""
End Sub

Private Sub equals_Click()
b = Val(Text.Text)
Select Case opr
Case "+": Text.Text = a + b
Case "-": Text.Text = a - b
Case "*": Text.Text = a * b
Case "/": Text.Text = a / b
End Select
End Sub

Private Sub Form_Load()

End Sub

Private Sub multiply_Click()
a = Val(Text.Text)
opr = "*"
Text.Text = ""
End Sub

Private Sub subtract_Click()
a = Val(Text.Text)
opr = "-"
Text.Text = ""
End Sub


 
My IT Life © 2011-2014|Gene Rose