0% found this document useful (0 votes)
105 views

VB Calculator

The document provides an introduction and overview of Visual Basic programming language. It discusses what Visual Basic is, the types of programs that can be created with it, and describes the Visual Basic integrated development environment. It also provides step-by-step instructions for creating a basic calculator application with Visual Basic, including designing the user interface, setting properties, and writing code for number and arithmetic buttons.

Uploaded by

Aditya Raj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

VB Calculator

The document provides an introduction and overview of Visual Basic programming language. It discusses what Visual Basic is, the types of programs that can be created with it, and describes the Visual Basic integrated development environment. It also provides step-by-step instructions for creating a basic calculator application with Visual Basic, including designing the user interface, setting properties, and writing code for number and arithmetic buttons.

Uploaded by

Aditya Raj
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Acknowledgements

The goal was fixed, the moves were calculated, and I moved full
of enthusiasm, figurant keen interested there were time, when it
proved to be on uphill task, the goal seeming beyond my reach. But
as the work progressed my determination and will power grow
stronger and the completion of this work further confirmed my belief
that, "Where there is a will there is a way".

I am thankful to my guide Mr. Tripurari Kumar and our senior Raj


Kumar for his constant encouragement and support to complete
the project. He motivated me through his personal and his "never
say die" spirit.

I specially would like to express my gratitude and debtless to my


friends some way or the other and been linked with the project from
the one.

I am also grateful to the project lab for providing me conductive


environment for the development of this project. I would not forget
to think my parents and friends for their readily avoidable counsel
and advice during the project.
INTRODUCTION
Visual Basic: -

1.1 The concept of computer programming


Programming means designing a set of instructions to instruct
the computer to carry out certain jobs that are very much faster than
human beings can do. The earliest programming language is called
machine language which uses the binary code (comprises 0 and 1) to
communicate with the computer. However, the machine language is
extremely difficult to learn. Fortunately , scientists have invented
some high-level programming languages that are much easier to
master. Among the high-level programming languages are
Java, Javascript, C, C++, C# and Visual Basic.

1.2 What is Visual Basic?


Visual Basic is a third-generation event-driven programming
language first released by Microsoft in 1991. It evolved from the
earlier DOS version called BASIC. BASIC means Beginners' All-
purpose Symbolic Instruction Code. Since then Microsoft has
released many versions of Visual Basic, from Visual Basic 1.0 to the
final version Visual Basic 6.0. Visual Basic is a user-friendly
programming language designed for beginners, and it enables
anyone to develop GUI window applications easily.

In 2002, Microsoft released Visual Basic.NET(VB.NET) to replace


Visual Basic 6. Thereafter, Microsoft declared VB6 a legacy
programming language in 2008. Fortunately, Microsoft still provides
some form of support for VB6. VB.NET is a fully object-oriented
programming language implemented in the .NET Framework. It was
created to cater for the development of the web as well as mobile
applications. However, many developers still favor Visual Basic 6.0
over its successor Visual Basic.NET.

1.3 What programs can you create with Visual Basic 6?


In VB 6, you can create any program depending on your
objective. For math teachers, you can create mathematical programs
such as Geometric Progression, Quadratic Equation
Solver, Simultaneous Equation Solver ,Prime Number Tester, Factors
Finder, Quadratic Function Graph Plotter and so on. For science
teachers, you can create simulation programs such
as Projectile, Simple Harmonic Motion, Star War  etc. If you are in
business, you can also create business applications such as inventory
management system , Amortization Calculator , investments
calculator, point-of-sale system, payroll system, accounting program
and more to help manage your business and increase productivity.
For those of you who like games , you can create programs such
as slot machine, reversi, tic tac toe and more. Besides, you can create
multimedia programs such as Smart Audio Player, Multimedia Player 
and more. Indeed, there is no limit to what program you can create.

1.4 The Visual Basic 6 Integrated Development


Environment
Before you can write programs in VB 6, you need to install Visual
Basic 6 compiler on your computer. You can purchase a copy of
Microsoft Visual Basic 6.0 Learning Edition or Microsoft Visual Basic
Professional Edition from Amazon.com, both are vb6 compilers.
Besides, you can also buy it from eBay at Microsoft Visual Basic 6.0 6
Professional PRO MSDN Library Manual Service Pack. If you have
already installed Microsoft Office in your PC or laptop, you can also
use the built-in Visual Basic Application in Excel to start creating
Visual Basic programs without having to spend extra cash to buy the
VB6 compiler.

You can also install VB6 on Windows 10 but you need to follow
certain steps otherwise the installation will fail. First, you need to run
setup as administrator. Next, you need to use custom installation.
Clear the checkbox for Data Access. If you don't, set up will hang at
the end of the installation. Finally, click next and wait for the
installation to complete. For complete instructions, please follow this
link Install VB6 on Windows 10

After installing the vb6 compiler, the icon will appear on your
desktop or in your programs menu. Click on the icon to launch the
VB6 compiler. On start up, Visual Basic 6.0 will display the following
dialog box as shown in Figure 1.1.

Figure 1.1: New Project Dialog


You can choose to either start a new project, open an existing project
or select a list of recently opened programs. A project is a collection
of files that make up your application. There are various types of
applications that we could create, however, we shall concentrate on
creating Standard EXE programs (EXE means executable). Before you
begin, you must think of an application that preferably have
commercial ,educational or recreational value. Next, click on the
Standard EXE icon to go into the actual Visual Basic 6 programming
environment.

When you start a new Visual Basic 6 Standard EXE project, you will
be presented  with the Visual Basic 6 Integrated Development
Environment (IDE). The Visual Basic 6 Integrated Programming
Environment is shown in Figure 1.2. It consists of the toolbox, the
form, the project explorer and the properties window.

Figure 1.2: VB6 Programming Environment


The Form is the primary building block of a Visual Basic 6 application.
A Visual Basic 6 application can actually comprise many forms, but
we shall focus on developing an application with one form first. We
will learn how to develop applications with multiple forms later.
Before you proceed to build the application, it is a good practice to
save the project first. You can save the project by
selecting Save Project from the File menu, assign a name to your
project and save it in a certain folder.

2.1 Creating Your First Application

First of all, launch Microsoft Visual Basic 6 compiler that you have
installed earlier. In the New Project Dialog , choose Standard EXE to
enter Visual Basic 6 integrated development environment. In the VB6
IDE, a default form with the name Form1 will appear. Next, double
click on Form1 to bring up the source code window for Form1, as
shown in Figure 2.1.

The top of the source code window consists of a list of objects and
their associated events or procedures. In the source code window,
the object displayed is Form1 and the associated procedure is Load.
DESIGN TIME SCREEN

(Fig:- Home Page)

(Fig:- With Output Display)


(Fig:- Main Designed Page)

(Fig: - Compiled & Run Page)


Properties Window

(Fig:- Properties of Text Box)

In this we change the property of Text Box and we enter the name of
Text Box is ‘boxresult’ and caption is removed, Also we changed the
position and text style.
(Fig:- Properties of all numbers)
(Fig: - Properties of Arthematical Properties)
(Fig:- Properties Of Eqaul and Cancel Button)
Coding

For 1: -
Private Sub btn1_Click()
boxresult.Text = boxresult.Text + "1"

End Sub

For 2: -
Private Sub btn2_Click()
boxresult.Text = boxresult.Text + "2"

End Sub

For 3: -
Private Sub btn3_Click()
boxresult.Text = boxresult.Text + "3"

End Sub

For 4: -
Private Sub btn4_Click()
boxresult.Text = boxresult.Text + "4"

End Sub

For 5: -
Private Sub btn5_Click()
boxresult.Text = boxresult.Text + "5"

End Sub

For 6: -
Private Sub btn6_Click()
boxresult.Text = boxresult.Text + "6"

End Sub

For 7: -
Private Sub btn7_Click()
boxresult.Text = boxresult.Text + "7"

End Sub

For 8: -
Private Sub btn8_Click()
boxresult.Text = boxresult.Text + "8"

End Sub

For 9: -
Private Sub btn9_Click()
boxresult.Text = boxresult.Text + "9"

End Sub

For 0: -
Private Sub btn0_Click()
boxresult.Text = boxresult.Text + "0"

End Sub

For . : -
Private Sub btndecimal_Click()
boxresult.Text = boxresult.Text + "."

End Sub

For Sum: -
Private Sub btnsum_Click()
operator = "+"
n1 = Val(boxresult.Text)
boxresult.Text = ""

End Sub

For Subtraction: -
Private Sub btnsub_Click()
operator = "-"
n1 = Val(boxresult.Text)
boxresult.Text = ""

End Sub

For Multiplication: -
Private Sub btnsub_Click()
operator = "-"
n1 = Val(boxresult.Text)
boxresult.Text = ""

End Sub

For Division: -
Private Sub btndiv_Click()
operator = "/"
n1 = Val(boxresult.Text)
boxresult.Text = ""

End Sub

For Equal: -
Private Sub btnequal_Click()
n2 = Val(boxresult.Text)
Select Case operator
Case "+"
result = n1 + n2
Case "-"
result = n1 - n2
Case "*"
result = n1 * n2
Case "/"
result = n1 / n2
End Select
boxresult.Text = result

End Sub

For Clear: -
Private Sub btnclear_Click()
boxresult.Text = ""

End Sub

For General (Defined For All Program): -


Dim n1, n2, result As Double
Dim operator As String

For Result Box: -


Private Sub boxresult_Change()

End Sub

OUTPUT TIME SCREEN

(Fig:- Output WIndows)

Bibliography
The following books have been referred during the preparation
of this project: -
1. Various websites like Wikipedia, YouTube,
2. Visual Basic Programming: Black Book for Visual Basic
Programming, by John Steven Horzler
3. Previous work experiences on VB6.0

You might also like