Calculator 7
Calculator 7
Calculator:
Concordia college industrial
area near rasool medical
centre Gujrat
2
3
Prepared by:
Asad Ullah Akram(329735)
4
Table of contents:
Table of contents:
Project Name:..............................................................................................................................................................1
Prepared By:................................................................................................................................................................4
Dedication.....................................................................................................................................................................6
ACKNOWLEDGEMENT...........................................................................................................................................7
Declaration:..................................................................................................................................................................8
INTRODUCTION:.........................................................................................................................................................9
TOOLS:..............................................................................................................................................................................10
Designing the form:.................................................................................................................................................13
Working of calculator:...........................................................................................................................................17
Coding:............................................................................................................................................................................ 20
Benefits of Calculator:...........................................................................................................................................28
Future scope................................................................................................................................................................29
5
Dedication:
We dedicate this project to our parents and
teachers by virtue of those prayers, we have
been able to reach at this position and whose
hands always raised for pray for our well-being
,even at this moment of time.
ACKNOWLEDGEMENT:
All and every praise to ALLAH ALMIGHTY, most
magnificent, beneficent and most merciful, who
capacitate me to complete this task. I pray to Him
for His guidance and protection in whole of life.
Formost, I would like to pay my sincere gratitude
to supervisor Sir Saqib Shah head of computer
science Department for their constant support in
the completion of the task. Special thanks to
respected teachers, especially Sir ALI SHOKAT.
6
Their guidance and encouragement, patience
listening and intellectual brought up.
Declaration:
We, students of bachelor of science, hereby
declare
that we have successfully completed this project
on
calculator. We also declare that this is our original
work, as part of our academic course.
INTRODUCTION:
Our project belongs to a simple calculator. It is
basically used in Mathematics. We often used it in
our daily routine matters. It can perform different
task such as addition(+) , subtraction(-),
multiplication(*) , division(/), exponent(^) and
7
sqRoot.
TOOLS:
•Command Button control
•Text Box control
•Operators
Command button control:
All calculatuion are
normally performed when the user clicks on a
button with
mouse.
TextBox control:
It is normally used to get input from the
user.
Operators:
we used different operators like
+,,*,/ etc.
8
Plus(+):
This operator is used to add two numbers. For
example:
2+5=7
Subtract(-):
This operator is used to subtract two
numbers. For example:
5-2=3
Multiplication(*):
This operator is used to multiply
two numbers. For example:
5*2=10
Division(/):
This operator is used to divide two
numbers. For example:
10/2=5
Exponent(^):
9
This operator is used to raise the power.
For example:
2^3=8
SqRoot:
This operator is used to sqRoot the number.
For example:
9 sqRoot=3
10
Designing the form:
We used 10 command button for the numbers 0 to
9. When a button is clicked its value will be
transferred to a display area which will be a text
box. Once a number is transferred to the text box
we can click on the plus(+) button. Then we need to
click back on another number. To get the answer,
we click on the equal sign(=). To clear the display
,we have a clear button.
If you haven’t already, create
a new project. Save it as calculator to your new
form,first add ten buttons(you can add one,then
copy and paste the rest) now we use Array of
buttons to make their codding in one button. The
buttons should have the following properties:
Name:btn plus a number (cmdbtn one, cmdbtn
two, cmdbtn three etc)
Text:A cmdbtn from 0 to 9.Different one for each
11
cmdbtn, obviously, Next, add a textbox. set the
following properties
for the textbox:
Textbox:
Name: text1
Text: erase the default name and leave it empty
Font:MS Sans Serif, Bold ,14 Plus
Button:
Name: cmdplus
Font: MS Sans Serif, Bold ,14
Backcolor:&H00C0FFFF8 Equal
Button:
Name:cmdequal
Font:MS Sans Serif, Bold ,14
Backcolor:&H00C0FFFF8
Subtract button:
Name:cmdsubtract
Font:MS Sans Serif,Bold,14
12
Backcolor:&H00C0FFFF8
Multiplicatin button:
Name:cmdmultiply
Font:MS Sans Serif,Bold,14
Backcolor:&H00C0FFFF8
Division button:
Name:cmddivide
Font:MS Sans Serif, Bold, 14
Backcolor:&H00C0FFFF8 Clear
Button:
Name:cmdclear
Font:MS Sans Serif,Bold,14
Backcolor:&H00FFFFC0&
Exit button:
Name:cmdexit
Font:MS Sans Serif,Bold,14
Backcolor:&H00FFFFC0&
Designing of the form is finished, it look like
13
something as:
Working of calculator:
When we open the calculator its all buttons are
disabled:
14
When we click on the On button all others button are
working:
15
Now we click on another button which is ‘3’:
16
Flow chart
17
Flow diagram
18
ER DIAGRAM
Coding
Dim a as Variant
Dim op As String
Private Sub cmdonClick()
If cmd_on.Caption = "&On" Then
For i = 0 To 9 Command1(i).Enabled = True
Next i text1.Enabled = True
19
cmd_on.Caption = "Off"
ElseIf cmd_on.Caption = "Off" Then
Unload Me
End If
End Sub
Private Sub cmdclearClick()
a = Val(text1) text1 = ""
End Sub
Private Sub Cmddivide_Click()
a = Val(text1) op = "/" text1
= ""
End Sub
Private Sub cmdequal_Click()
If op = "+" Then text1 = a +
Val(text1)
ElseIf op = "-" Then text1 = a -Val(text1) ElseIf
20
op = "*"
Then text1 = a * Val(text1)
ElseIf op = "/" Then text1 = a / Val(text1)
ElseIf op = "^" Then text1 = a ^ Val(text1)
End If
End Sub
Private Sub cmdexponent_Click()
op = "^" text1 = ""
End Sub
Private Sub cmdmultiply_Click()
a = Val(text1) op = "*" text1 =
"" End Sub
Private Sub cmdplusClick()
a = Val(text1) op = "+"
text1 = ""
End Sub
21
Private Sub cmdsubtract_Click()
a = Val(text1) op = "-" text1 =
""
End Sub
Private Sub Command1_Click(index As Integer)
text1.Text
= text1 & Command1(index).Caption End Sub
Private Sub Command21_Click() text1.Text
= Sqr(Val(text1))
End Sub
Private Sub Form_Load()
For i = 0 To 9
Command1(i).Enabled = False
Next i text1.Enabled = False
End Sub
22
Benefits of Calculator:
•This system makes math interesting.
•It helps in verification of answer.
•This is a flexible mentl system.
•This system helps in removing the
unnecessary
burden.
•Students can solve problems at a
more
reasonable time frame.
•Prevents silly mistakes in
computation.
Future scope
•Our project will be able to implement
23
in future
after making some changes and
modifications as
we make our project at a very low
level. So the
modifications that can be done in our
project are:
•To make it screen touch so no need
to touch key
buttons and one more change which
can be made
is to add snaps of the person who use
it...
24
Certificate:
This is certify that the mini project
titled
“CALCULATOR” has been completed
in the academic
year 2021-23. It is not published. We
complete this
project on 06thSeptember,2023.
Under the guidence of Prof. Saqib Ali
Shah.
25