You are on page 1of 9

MAKE A PROJECT OF CALCULATOR IN

VISUAL BASIC
 First we select the Standard exe item in the view
project dialog box, opening Visual
Basic itself.
 Then we select the Textbox from the Toolbox and make
a textbox on the form.
 Then we select the command button from the tool box
from the tool box we make buttons 0, 1, 2, 3, 4 … 9, +,
=,-,*, /, clear.
 After these all buttons are made. Then we need the
buttons to be coded. Thus double click on the button
numbered “1”, following coding is done:

Private sub Command 1-Click ()


Text1.Text = Text 1. Text + “1”
End Sub
 Double clicking on the Button “2”
Private sub Command 2-Click ()
Text1.Text = Text 1. Text + “2”
End Sub

 Double clicking on the Button “3”

Private sub Command 3-Click ()


Text1.Text = Text 1. Text + “3”
End Sub

 Double clicking on the Button “4”

Private sub Command 4-Click ()


Text1.Text = Text 1. Text + “4”
End Sub

 Double clicking on the Button “5”

Private sub Command 5-Click ()


Text1.Text = Text 1. Text + “5”
End Sub

 Double clicking on the Button “6”

Private sub Command 6-Click ()


Text1.Text = Text 1. Text + “6”
End Sub

 Double clicking on the Button “7”

Private sub Command 7-Click ()


Text1.Text = Text 1. Text + “7”
End Sub

 Double clicking on the Button “8”

Private sub Command 8-Click ()


Text1.Text = Text 1. Text + “8”
End Sub
 Double clicking on the Button “9”

Private sub Command 9-Click ()


Text1.Text = Text 1. Text + “9”
End Sub

 Double clicking on the Button “0”

Private sub Command 10-Click ()


Text1.Text = Text 1. Text + “0”
End Sub

 Double clicking on the Button “.”

Private sub Command 11-Click ()


Text1.Text = Text 1. Text + “.”
End Sub

 Double clicking on the Button “+”


Private sub Command 12-Click ()
a= Text 1. Text
Text1.Text = ”+”
d=1
End Sub

 Double clicking on the Button “-”

Private sub Command 13-Click ()


a= Text 1. Text
Text1.Text =”-”
d=3
End Sub

 Double clicking on the Button “*”

Private sub Command 14-Click ()


a= Text 1. Text
Text1.Text =”*”
d=3
End Sub

 Double clicking on the Button “/”

Private sub Command 15-Click ()


a= Text 1. Text
Text1.Text =”/”
d=4
End Sub

 Double clicking on the Button “Square”

Private sub Command 16-Click ()


a= Text 1. Text
Text1.Text =”*”
C=a*a
Text1.Text = c
End Sub
 Double clicking on the Button “Factorial”

Private sub Command 17-Click ()


a= Text 1. Text
Text1.Text =”i”
e=1
for i = s to step-1
e = e*i
Text1.Text = e
End Sub

 Double clicking on the Button “Clear”

Private sub Command 18-Click ()


Text1.Text ( )
End Sub

 Double clicking on the Button “=”

Private sub Command 19-Click ()


b = Text1.Text
Select case d%
Case 1: c= a + b
Text1.Text = c
Case 2: c = a - b
Text1.Text=c
Case 3: c= a * b
Text1.Text = c
Case 4: c= a / b
Text1.Text = c
End Select
End Sub

Following figure shows how a


calculator made in Visual Basic
Looks :

You might also like