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


6 comments :

  1. obat kuat said... :

    I love your blog, I look forward to seeing more from you. Do you run any other sites? thanks

  1. Unknown said... :

    Thanks for sharing stuff of this kind .Good information and impressive. I really like your information sharing on basic calculator .

  1. Gene said... :

    thanks for appreciating it :)

  1. ashu said... :

    such simple programs r very useful to learn VB....thanks for sharing

  1. Unknown said... :

    gene tnx sa info ahm do you have installer sa visual basic???

  1. Gene said... :

    @sharmaine you can visit this site http://microsoft-visual-basic.en.softonic.com/ sorry i no longer have the installer but try downloading it online.

Post a Comment

 
My IT Life © 2011-2014|Gene Rose