VB Tutorial: How to make a simple calculator

SIMPLE CALCULATOR IN VISUAL BASIC 6.0
STEP ONE
                                I.            Open your VB6.0 IDE. Double.
                              II.            Click on “Standard EXE” (A Worksheet Form Appears).
 

 
STEP TWO
                                I.            Expand the form a little to the right.
                              II.            Add four command Buttons and three textboxes


STEP THREE
                                I.            Edit the properties of the added objects as given below:
a.       Command1
                                                                                       i.      Name : cmdAdd
                                                                                     ii.      Caption : ADD
b.      Command2
                                                                                       i.      Name : cmdSub
                                                                                     ii.      Caption : SUBTRACT
c.       Command3
                                                                                       i.      Name : cmdMul
                                                                                     ii.      Caption : MULTIPLY
d.      Command2
                                                                                       i.      Name : cmdDiv
                                                                                     ii.      Caption :DIVISION
e.      Text1
                                                                                       i.      Name : txtFirstNum
                                                                                     ii.      Text : _Leave this blank
f.        Text2
                                                                                       i.      Name : txtSecondNum
                                                                                     ii.      Text :  _Leave this blank
g.       Text3
                                                                                       i.      Name : txtAnswer
                                                                                     ii.      Text :  _Leave this blank



STEP FOUR
                                I.            Starting the Coding:
a.       Double-Click on the ADD button and it opens its Private Sub which is in this form:
Private Sub cmdAdd_Click()

End Sub
                                                In the private sub input the following code:
txtAnswer.Text = Val(txtFirstNum.Text) + Val(txtSecondNum)
b.      Double-Click on the SUBTRACT button and it opens its Private Sub which is in this form:
Private Sub cmdSub_Click()

End Sub
                                                In the private sub input the following code:
txtAnswer.Text = Val(txtFirstNum.Text) - Val(txtSecondNum)
c.       Double-Click on the MULTPLY button and it opens its Private Sub which is in this form:
Private Sub cmdMul_Click()

End Sub
                                                In the private sub input the following code:
txtAnswer.Text = Val(txtFirstNum.Text) * Val(txtSecondNum)
d.      Double-Click on the DIVISION button and it opens its Private Sub which is in this form:
Private Sub cmdDiv_Click()

End Sub
                                                In the private sub input the following code:
txtAnswer.Text = Val(txtFirstNum.Text) / Val(txtSecondNum)




STEP FIVE
                Finally, run the program.


THE END.

No comments: