International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 1 Issue 10, December- 2012
Software-Based Scientific Calculator Using Visual Basic.Net
Isizoh A. N.1 Anazia A.E.2
Dept. of Electronic and Computer Engineering, Dept. of Electrical Engineering,
Nnamdi Azikiwe University, Awka, Nigeria. Nnamdi Azikiwe University, Awka, Nigeria.
Okide S. O.3 Okwaraoka C.A.P.4
Dept. of Computer Science, Dept. of Electrical/Electronics Engineering,
Nnamdi Azikiwe University, Awka, Nigeria. Federal Polytechnic , Nekede, Imo State, Nigeria
Abstract Visual Basic (VB) starts from Visual Basic 1.0 up to
This Paper presents the development of a software- Visual basic.Net (VB.Net). The .Net is from VB 7.0
based scientific calculator using Visual Basic.Net upwards, and represents the entire range of VB
(VB.Net). Visual Studio 2008 package was used and technology and concepts that form a platform on
IIJJET
it contains the VB.Net framework. The calculator which you can develop applications [3].
E RR
design was done in the visual “FORM” environment
of the VB .Net, while the control program was written Visual Studio 2008 package was used for this work.
in “Form1.vb” by double clicking the buttons on the It contains the VB.Net framework which was used to
scientific calculator. The program was run and it was develop the software-based scientific calculator. The
error-free. The Scientific calculator was implemented calculator was developed in the “FORM”
in a Windows Operating System (OS) because Visual environment of the Visual Studio; while the control
Basic .Net is a Windows-based software. program was written by double clicking the buttons
in the “Form 1.vb.
Keywords: Visual Basic .NET, scientific There are two major classes of operating tools for
calculator, label and toolbox. software development using Visual Basic .Net [4].
They are the Toolbox and the Properties. Toolbox is
1. Introduction grouped into classes, namely; All Windows Form,
Common Controls, Containers, Menus & Toolbars,
Data, Components, Printing, Dialogs, WPF
A Calculator is a small (often pocket-sized), usually
Interoperability, Reporting, and General. While
inexpensive electronic device used to perform the
Properties have Accessibility, Appearance, Behavior,
basic operations of arithmetic. Modern calculators are
Data, Design, Focus, Layout, Misc, and Window
more portable than most computers, though most
Style [5].
Palmtops are comparable in size to handheld
calculators [1].
2. The System Development
This software-based scientific calculator was
developed using Visual Studio. Visual Studio is an To develop this calculator, open Visual Studio 2008,
Integrated Development Environment (IDE), and create the new design in the „FORM‟
providing a single interface for any number of environment. Note the needed information, like the
languages, including Visual Basic. The purpose of an names that will be given to the various buttons and
IDE is to combine the editing, debugging, and the Label for information display. In order to open
compiling components of software development into the environment for system development, the
a single interface for a programmer [2]. following steps are to be taken:
www.ijert.org 1
International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 1 Issue 10, December- 2012
1) Launch your Visual Basic .NET or Visual Studio
software. After loading, the software will open. One thing with VB.Net is that when using it, the
2) At the bottom of the screen, there are two buttons: work must be saved first before designing the
"Open project" and "Create project". To get started, program.
click on the "Create project" button. 3) Type the file name which is used for saving the
The Visual Basic.NET design time environment will work, and click on ok. The “FORM” environment
open. It will look like figure 1. will come out. This “FORM” is the design interface.
IIJJET
E RR
Fig. 1. A Visual Studio design interface containing the “FORM”
4) Start the proper design by positioning the Label for Label: It provides run-time information or descriptive
display and the buttons as keys. These are known as text for a control. It is used for writing or labelling
Controls, and are kept in the Toolbox for ease of use. items in the form environment. If this control is used,
The Toolbox can be found on the left hand side of the data on it cannot be tampered because it has no
screen. cursor inside it, unlike the Textbox [7]. It was used in
To display all the tools, move the mouse over the this work for designing the „screen area‟ for the
Toolbox icon. There are seven categories of tools display of the numbers pressed and the mathematical
available. The Toolbox to be working with first is the operation together with the result of any calculation.
Common Controls Toolbox. To see the tools, click on
the plus symbol next to Common Controls. 2.2. Design procedure for the Scientific
calculator
2.1. Common Controls in VB.Net Used for the
System development 1) Drag the needed buttons from the ToolBox and
drop them inside the “FORM”.
Button: This is used to raise an event when a user 2) Copy and paste the buttons to the corresponding
clicks on it. It is for writing most programs. Here, it number of numeric buttons and Math functions
was used in the design of the „number buttons‟ like buttons that are needed.
1, 2, 3, 4, etc and „mathematical functions buttons‟ On the right hand side of the design environment,
like there are Properties box. This is the area that controls
/, -, +, x, etc. the design “FORM”. The Properties Box of the
Visual Studio is shown in figure 2.
TextBox: It enables the user to enter text, and Click on each button and at the Properties box,
provides multiline editing and password character change the names of the buttons in the “Text”
masking [6]. Cursor can be placed here. It was not Properties to 0,1,2,3,4,5,6,7,8,9,sin,/,+,-. log, cos, tan,
used in this work. sqr, etc.
www.ijert.org 2
International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 1 Issue 10, December- 2012
Fig. 2. The Properties box of the Visual Studio
3) Also click on the Math function buttons and 5) When any of the buttons is double clicked, it takes
likewise change their names at the “Text” Properties one to the code area from where one writes the code
to +, -, *, /, etc. that defines the function of that button.
4) Drag “Label” from the Toolbox and it drop inside The layout design is called the form 1.vb (design),
the FORM. This is used for the display of shown in figure 3.
information.
IIJJET
E RR
Fig. 3. The designed view of the scientific calculator
Double clicking any of the buttons or keys, opens the
code window for programming.
program in the code environment by debugging.
3. System Implementation When this is done, the developed software will be
displayed. It works like ordinary physical calculator
Implementation of this visual calculator is not used for basic calculations. Punch the number buttons
difficult. This system must be implemented in a you want and the mathematical function you want to
computer with Windows Operating System, because carry out, punch the “=” button to give you the result.
VB.Net is a Windows-based software. This result will be displayed on the “Display” label,
Just install this Scientific calculator software in a as shown in figure 4.
computer with Windows Operating System. Run the
www.ijert.org 3
International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 1 Issue 10, December- 2012
Fig. 4. The software-based Scientific Calculator
4. Conclusion End If
IIJJET
With the introduction of the .Net framework and cleardisplay = False
VB.Net language, software development has been lblDisplay.Text = lblDisplay.Text + sender.text
E RR
greatly facilitated with easy use of objects (forms, End Sub
buttons, boxes, etc) which can be inserted and then Private Sub btnCancel_Click(ByVal sender As
their functions specified by coding. System.Object, ByVal e As System.EventArgs)
This paper has succeeded in giving an insight into the Handles btnCancel.Click
Microsoft‟s .Net framework and that of Visual Basic lblDisplay.Text = " "
Programming language; and the use of the language End Sub
in the software development of a Software-based Private Sub btnplus_Click(ByVal sender As
Scientific calculator. Other software-based System.Object, ByVal e As System.EventArgs)
calculating systems like Visual loan calculator, Handles btnplus.Click
weather forecast analysing software, etc, can as well Operand1 =
be designed using VB.Net. Val(lblDisplay.Text) Operators
= "+"
5. The Developed Software (Program) cleardisplay =
True End Sub
Imports System.Math Private Sub btnminus_Click(ByVal sender As
Public Class Form1 System.Object, ByVal e As System.EventArgs)
Dim Operand1, Operand2, ans As Handles btnminus.Click
Double Dim Operators As String Operand1 =
Dim cleardisplay As Boolean Val(lblDisplay.Text) Operators
Private Sub Form1_Load(ByVal sender As = "-"
System.Object, ByVal e As System.EventArgs) cleardisplay =
Handles MyBase.Load True End Sub
End Sub Private Sub btndiv_Click(ByVal sender As
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs) Handles btndiv.Click
Handles btn1.Click, btn0.Click, btn2.Click, Operand1 =
btn3.Click, btn4.Click, btn5.Click, btn6.Click, Val(lblDisplay.Text) Operators
btn7.Click, btn8.Click, btn9.Click = "/"
If cleardisplay Then cleardisplay =
lblDisplay.Text = " True End Sub
" Private Sub btnmul_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles btnmul.Click
Operand1 = Val(lblDisplay.Text)
www.ijert.org 4
International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 1 Issue 10, December- 2012
Operators = "*" lblDisplay.Text = lblDisplay.Text +
cleardisplay = True sender.text
End Sub End If
Private Sub btnequal_Click(ByVal sender As End Sub
System.Object, ByVal e As System.EventArgs) Private Sub btnsin_Click(ByVal sender As
Handles btnequal.Click System.Object, ByVal e As System.EventArgs)
Operand2 = Handles btnsin.Click
Val(lblDisplay.Text) Select Case Operand1 = Val(lblDisplay.Text)
Operators ans = Math.Sin(Operand1)
Case "+" lblDisplay.Text = ans
ans = Operand1 + Operand2 End Sub
Case "-" Private Sub btnCos_Click(ByVal sender As
ans = Operand1 - Operand2 System.Object, ByVal e As System.EventArgs)
Case "/" Handles btnCos.Click
ans = Operand1 / Operand2 Operand1 = Val(lblDisplay.Text)
Case "*" ans = Math.Cos(Operand1)
ans = Operand1 * Operand2 lblDisplay.Text = ans
Case "^" End Sub
ans = Operand1 ^ Operand2 Private Sub btnTan_Click(ByVal sender As
End Select System.Object, ByVal e As System.EventArgs)
lblDisplay.Text = ans Handles btnTan.Click
End Sub Operand1 = Val(lblDisplay.Text)
Private Sub btnsqr_Click(ByVal sender As ans = Math.Tan(Operand1)
System.Object, ByVal e As System.EventArgs)
IIJJET
lblDisplay.Text = ans
Handles btnsqr.Click End Sub
E RR
Operand1 = Val(lblDisplay.Text) Private Sub btnlog_Click(ByVal sender As
ans = Operand1 ^ 2 System.Object, ByVal e As System.EventArgs)
lblDisplay.Text = ans Handles btnlog.Click
End Sub Operand1 = Val(lblDisplay.Text)
Private Sub btnpower_Click(ByVal sender As ans = Math.Log10(Operand1)
System.Object, ByVal e As System.EventArgs) lblDisplay.Text = ans
Handles btnpower.Click End Sub
Operand1 = End Class
Val(lblDisplay.Text) Operators
= "^"
cleardisplay = 6. References
True End Sub
[1] Watkins Perkins, “Programming in the .NET
Private Sub btnqube_Click(ByVal sender As Environment”, Addison Wesley, London, 2008.
System.Object, ByVal e As System.EventArgs) [2] Stroo Eric and Stuart J. Stuple, “Microsoft Visual Basic
Handles btnqube.Click Programmers Guide”, Microsoft Press, USA,
Operand1 = Val(lblDisplay.Text) 2009.
ans = Operand1 ^ 3 [3] Hutson Michael, “Introduction to Visual Basic .Net”,
lblDisplay.Text = ans John Wiley and Sons, New York, 2008.
End Sub [4] C. S. French, “Computer Science”, Ashford Colour
Press, Gosport, Hants, Great Britain, 2009,
Private Sub btnsqrt_Click(ByVal sender As
[5] Wright Peter, “Beginning Visual Basic .Net”, Wrox
System.Object, ByVal e As System.EventArgs) Press Ltd, Canada, 2009.
Handles btnsqrt.Click [6] Ochi – Okorie A. S., “Computer Fundamentals:
Operand1 = Val(lblDisplay.Text) Introduction and Utilization”, Solid Rock
ans = Operand1 ^ 0.5 Computer Press, Enugu, Nigeria,
lblDisplay.Text = ans 2008.
End Sub [7] Craig Utley, “A Programmer‟s Introduction to Visual
Private Sub btndot_Click(ByVal sender As Basic .Net”, Sams Publishing, Indianapolis, USA,
System.Object, ByVal e As System.EventArgs) 2007.
Handles btndot.Click
If lblDisplay.Text.IndexOf(".") > 0 Then
Exit Sub
Else
www.ijert.org 5