Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Visual Basic in Bsc computerScience, Lecture notes of Visual Sociology

Visual Basic notes for Bsc Computer Science Student

Typology: Lecture notes

2018/2019

Uploaded on 12/17/2019

hemavathi-j
hemavathi-j 🇮🇳

5

(3)

11 documents

1 / 115

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
VISUAL BASIC
VIJAYA COLLEGE Page 1
Lesson1: Introduction to Visual Basic 6
Before we begin Visual Basic 6 programming, let us understand some
basic concepts of programming. According to Webopedia, a computer
program is an organized list of instructions that, when executed,
causes the computer to behave in a predetermined manner. Without
programs, computers are useless. Therefore, programming means
designing or creating a set of instructions to ask the computer to carry
out certain jobs which normally are very much faster than human
beings can do.
Most people think that computer CPU is a very intelligent thing, which
in actual fact it is a dumb and inanimate object that can do nothing
without human assistant. The microchips of a CPU can only
understand two distinct electrical states, namely, the on and off states,
or 0 and 1 codes in the binary system. So, the CPU only understands
combinations of 0 and 1 code, a language which we called machine
language. Machine language is extremely difficult to learn and it is not
for us laymen to master it easily. Fortunately, we have many smart
programmers who wrote interpreters and compilers that can translate
human language-like programs such as BASIC into machine language
so that the computer can carry out the instructions entered by the
users. Machine language is known as the primitive language while
Interpreters and compilers like Visual Basic are called high-level
language. Some of the high level programming languages beside
Visual Basic are Fortran, Cobol, Java, C, C++, Turbo Pascal, and more
. Among the aforementioned programming languages, Visual Basic is
the most popular. Not only it is easily to learn because of its English-
like syntaxes, it can also be incorporated into all the Microsoft office
applications such as Microsoft words, Microsoft Excel, Microsoft
PowerPoint and more. Visual Basic for applications is known as VBA.
What programs can you create with Visual Basic 6?
With VB 6, you can create any program depending on your objective.
For example, you can create educational programs to teach science ,
mathematics, language, history , geography and so on. You can also
create financial and accounting programs to make you a more efficient
accountant or financial controller. For those of you who like games,
you can create those programs as well. Indeed, there is no limit to
what program you can create!
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Visual Basic in Bsc computerScience and more Lecture notes Visual Sociology in PDF only on Docsity!

VISUAL BASIC

VIJAYA COLLEGE Page 1

Lesson1: Introduction to Visual Basic 6

Before we begin Visual Basic 6 programming, let us understand some basic concepts of programming. According to Webopedia, a computer program is an organized list of instructions that, when executed, causes the computer to behave in a predetermined manner. Without programs, computers are useless. Therefore, programming means designing or creating a set of instructions to ask the computer to carry out certain jobs which normally are very much faster than human beings can do.

Most people think that computer CPU is a very intelligent thing, which in actual fact it is a dumb and inanimate object that can do nothing without human assistant. The microchips of a CPU can only understand two distinct electrical states, namely, the on and off states, or 0 and 1 codes in the binary system. So, the CPU only understands combinations of 0 and 1 code, a language which we called machine language. Machine language is extremely difficult to learn and it is not for us laymen to master it easily. Fortunately, we have many smart programmers who wrote interpreters and compilers that can translate human language-like programs such as BASIC into machine language so that the computer can carry out the instructions entered by the users. Machine language is known as the primitive language while Interpreters and compilers like Visual Basic are called high-level language. Some of the high level programming languages beside Visual Basic are Fortran, Cobol, Java, C, C++, Turbo Pascal, and more

. Among the aforementioned programming languages, Visual Basic is the most popular. Not only it is easily to learn because of its English- like syntaxes, it can also be incorporated into all the Microsoft office applications such as Microsoft words, Microsoft Excel, Microsoft PowerPoint and more. Visual Basic for applications is known as VBA.

What programs can you create with Visual Basic 6?

With VB 6, you can create any program depending on your objective. For example, you can create educational programs to teach science , mathematics, language, history , geography and so on. You can also create financial and accounting programs to make you a more efficient accountant or financial controller. For those of you who like games, you can create those programs as well. Indeed, there is no limit to what program you can create!

VISUAL BASIC

VIJAYA COLLEGE Page 2

The Visual Basic 6 Integrated Development Environment

On start up, Visual Basic 6.0 will display the following dialog box as shown in Figure 1.1. You can choose to 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 program). Now, click on the Standard EXE icon to go into the actual Visual Basic 6 programming environment.

VISUAL BASIC

VIJAYA COLLEGE Page 4

displayed as shown in figure 2.3. Some of the procedures associated

with the object Form1 are Activate, Click, DblClick (which means

Double-Click) , DragDrop, keyPress and more. Each object has its

own set of procedures. You can always select an object and write

codes for any of its procedure in order to perform certain tasks.

Figure 2.2: List of Object s (^) Figure 2.3: List of Procedures

You do not have to worry about the beginning and the end statements

(i.e. Private Sub Form_Load.......End Sub.); Just key in the lines in

between the above two statements exactly as are shown here. When

you press F5 to run the program, you will be surprise that nothing

shown up .In order to display the output of the program, you have to

add the Form1.show statement like in Example 2.1.1 or you can just

use Form_Activate ( ) event procedure as shown in example 2.1.2.

The command Print does not mean printing using a printer but it

means displaying the output on the computer screen. Now, press F5 or

click on the run button to run the program and you will get the output

as shown in figure 2.4.

VISUAL BASIC

VIJAYA COLLEGE Page 5

You can also perform arithmetic calculations as shown in

example 2.1.2. VB uses * to denote the multiplication operator and /

to denote the division operator. The output is shown in figure 2.3,

where the results are arranged vertically.

VISUAL BASIC

VIJAYA COLLEGE Page 7

Lesson 3-Working With Controls

Before writing an event procedure for the control to response to a user's input, you have to set certain properties for the control to determine its appearance and how it will work with the event procedure. You can set the properties of the controls in the properties window or at runtime.

VISUAL BASIC

VIJAYA COLLEGE Page 8

Figure 3.1 on the right is a typical properties window for a form. You can rename the form caption to any name that you like best. In the properties window, the item appears at the top part is the object currently selected (in Figure 3.1, the object selected is Form1). At the bottom part, the items listed in the left column represent the names of various properties associated with the selected object while the items listed in the right column represent the states of the properties. Properties can be set by highlighting the items in the right column then change them by typing or selecting the options

VISUAL BASIC

VIJAYA COLLEGE Page 10

3.2.1 The Text Box

The text box is the standard control for accepting input from the user

as well as to display the output. It can handle string (text) and

numeric data but not images or pictures. String in a text box can be

converted to a numeric data by using the function Val(text). The

following example illustrates a simple program that processes the

input from the user.

Example 3.

In this program, two text boxes are inserted into the form together

with a few labels. The two text boxes are used to accept inputs from

the user and one of the labels will be used to display the sum of two

numbers that are entered into the two text boxes. Besides, a

command button is also programmed to calculate the sum of the two

numbers using the plus operator. The program use creates a variable

sum to accept the summation of values from text box 1 and text box