DEPARTMENT OF
INFORMATION
TECHONLOGY
2020-2021
Micro Project Report
On
“CALCULATOR”
Academic year: 2020-21
Program code: IF4I
Course: GUI Application Development Using VB.NET
Course Code: 22034
Subject Teacher: Mrs. Shilpa Mathur
Group No: 8
ZAGDU SINGH CHARITABLE TRUST (REGD.)
THAKUR POLYTECHNIC
(An ISO 9001:2008 Certified Institute)
Thakur Complex, West to W. E. Highway, Kandivli (E), Mumbai – 400 101 (Accredited
by: National Board Of Accreditation)
MAHARASHTRA STATE
BOARD OF TECHNICAL EDUCATION
Certificate
This is to certify that:
Vidhi Agarwal- 04
Piyush Vishwakarma -24
Mahek Tiwari- 26
Gracy Verma- 51
Kinjal Mehta- 55
Mohd. Azaruddin Samani - 57
Nishith Shetty-58
of IV Semester of Diploma in Information Technology of Institute, THAKUR
POLYTECHNIC (Code:0522) have completed the Micro Project (Calculator)
satisfactorily in Subject -(GUI Application Development UsingVB.NET) for the
academic year 2020-21 as prescribed in the curriculum.
Place: Mumbai
Date: ………………………
_____________ ___________________ ________
Subject Teacher Head of the Department Principal
Acknowledgement
This acknowledgment transcends the reality of formality when we would like to express deep
gratitude and respect to all those people behind the screen who guided, inspired and helped me for
the completion of our project work.
This project would add as an asset to my academic profile. We express our sincere gratitude to
our respectful Principal Dr. S.M. Ganechari for enabling us to make use of laboratory and library
facilities liberally, that helped us a long way in carrying out our project work successfully.
We consider ourselves lucky enough to get such a good project. This project would add as an asset
to my academic profile. We express our gratitude to the help of the Head of the Department of
Information technology, Mrs.Suwarna Thakre, for her constant supervision, guidance and co-
operation throughout the project and we would like to express our thankfulness to our project
guide(subject teacher), Mrs. Shilpa Mathur for her constant motivation and valuable help through
the project work. We extend our sincere gratitude to our parents who have encouraged us with
their blessings to do this project successfully.
Finally we would like to thank to all our friends, all the teaching and non-teaching staff members
of the IF Department, for all the timely help, ideas and encouragement which helped throughout
in the completion of project.
Vidhi, Piyush,
Azaruddin
Graphical user interface
The graphical user interface (GUI) is a form of user interface that allows users to interact with
electronic devices through graphical icons and audio indicator such as primary notation, instead of
text-based user interfaces, typed command labels or text navigation. GUIs were introduced in
reaction to the perceived steep learning curve of command-line interfaces (CLIs), which require
commands to be typed on a computer keyboard.
The actions in a GUI are usually performed through direct manipulation of the graphical elements.
Beyond computers, GUIs are used in many handheld mobile devices such as MP3 players, portable
media players, gaming devices, smartphones and smaller household, office and industrial controls.
The term GUI tends not to be applied to other lower-display resolution types of interfaces, such as
video games (where head-up display (HUD) is preferred), or not including flat screens, like
volumetric displays because the term is restricted to the scope of two-dimensional display screens
able to describe generic information, in the tradition of the computer science research at the Xerox
Palo Alto Research Center.
Visual Basic .NET
Visual Basic .NET (VB.NET) is a multi-paradigm, object-oriented programming language,
implemented on the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to
its original Visual Basic language. Although the ".NET" portion of the name was dropped in 2005,
this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages released since 2002,
in order to distinguish between them and the classic Visual Basic. Along with Visual C#, it is one
of the two main languages targeting the .NET framework.
Microsoft's integrated development environment (IDE) for developing in Visual Basic .NET
language is Visual Studio. Most Visual Studio editions are commercial; the only exceptions are
Visual Studio Express and Visual Studio Community, which are freeware. In addition, the .NET
Framework SDK includes a freeware command-line compiler called vbc.exe. Mono also includes
a command-line VB.NET compiler.
First, create an Interface for your calculator which has the following:
• TextField
• Buttons for the numbers
• Buttons for the Operators
• Button for the Result
• Off, Clear, and Backspace Button
• In my Case, this is the interface I used.
• After that, set the variables for the operator, value 1, value 2, and other needed for
operations.
Option Explicit On
Public Class Form1
Dim Operand1 As Double
Dim Operand2 As Double
Dim [Operator] As String
Dim hasDecimal As Boolean
Dim tmpValue As Double
End Class
• Then, for each number buttons. For script below, my textfield named as "txtInput"
and "cmd1" for my number 1 button.
Private Sub cmd1_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles cmd1.Click
txtInput.Text = txtInput.Text & sender.text
End Sub
• For the operation buttons except for the square root button, follow the script below
and change the "[Operator]" value according to the operator you have set to the
button
1. Private Sub cmdAdd_Click(ByVal sender
As System.Object, ByVal e As
System.EventArgs) Handles
cmdAdd.Click
2. Operand1 = Val(txtInput.Text)
3. txtInput.Text = ""
4. txtInput.Focus()
5. [Operator] = "+"
6. End Sub
• And for the equal/result button. Use the following code below.
Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button23.Click
Dim Result As Double
Operand2 = Val(txtInput.Text)
Select Case [Operator]
Case “+”
Result = Operand1 + Operand2
txtInput.Text = Result.ToString()
Case “-“
Result = Operand1 – Operand2
txtInput.Text = Result.ToString()
Case “/”
Result = Operand1 / Operand2
txtInput.Text = Result.ToString()
Case “*”
Result = Operand1 * Operand2
txtInput.Text = Result.ToString()
Case “^”
Result = Operand1 ^ Operand2
txtInput.Text = Result.ToString()
Case “%”
Result = Operand1 * 1 / 100
txtInput.Text = Result.ToString()
End Select
txtInput.Text = Result.ToString()
End Sub
• Next is we will create the function that calculates the square root of the value when the
square root button will be clicked.
Private Sub cmdSqrtRoot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdSqrtRoot.Click
‘Make sure the input box has a value
If txtInput.Text.Length <> 0 Then
‘Assign our variable the value in the input box
tmpValue = CType(txtInput.Text, Double)
‘Perform the square root
tmpValue = System.Math.Sqrt(tmpValue)
‘Display the results in the input box
txtInput.Text = CType(tmpValue, String)
‘Clear the decimal flag
hasDecimal = False
End If
End Sub
• And lastly, creating a function for the button clear, backspace, and decimal.
‘for the Decimal
Private Sub cmdDecimal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdDecimal.Click
If InStr(txtInput.Text, “.”) > 0 Then
Exit Sub
Else
txtInput.Text = txtInput.Text & “.”
End If
End Sub
‘Clear Function
Private Sub CmdClearAll_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CmdClearAll.Click
txtInput.Text = “”
End Sub
‘Off Function
Private Sub cmdOFF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles CmdOff.Click
txtInput.Text = “”
End Sub
Output Screenshots
References
• GeeksforGeeks.g
• W3School
• Wikipedia.org