SlideShare a Scribd company logo
Chapter 1
Introduction to Visual Basic
1
R. BHUVANESWARI
ASST.PROFESSOR
DEPT OF COMPUTER SCIENCE AND APPLICATION
DKM COLLEGE FOR WOMEN
(AUTONOMOUS)
VELLORE
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 2
Objectives
 Machine language vs.. High-level language
 Procedure-oriented, object-oriented, and
event-driven languages
 Background of Visual Basic
 VB Integrated Development Environment
 Online documentation and Help features
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 3
Application Programs
Program - detailed set of instructions for a
computer to execute
Application programs (applications or apps) -
self-contained collection of programs that
perform a task for the end user
Programming language - formal language used
to give instructions to computers
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 4
History of Programming
Languages
Machine language
Procedure-oriented languages
Object-oriented languages
Event-driven languages
Natural languages
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 5
History of Programming
Languages
Machine Language
 different for each computer processor
 Procedure-Oriented Languages
 FORTRAN
 COBOL
 Pascal
 C
 Ada
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 6
History of Programming
Languages
Object-oriented languages
 Smalltalk
 C++
 Ada 95
Event-driven languages
 Visual Basic
 most Visual languages
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 7
History of Programming
Languages
Natural languages
 computer will accept a user’s native or
natural language, such as English
 Researchers continue to work in this
area
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 8
Background of Visual Basic
BASIC
 Beginner’s All-purpose Symbolic
Instruction Code
 By John Kemeny and Thomas Kurtz
 Designed to teach programming to
beginners
 BASIC language interpreter, one of
Microsoft’s first products
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 9
Background of Visual Basic
BASIC – (Beginners' All-purpose Symbolic Instruction Code)
 Included with DOS
 QBASIC - included with DOS Version 5 -
subset of BASIC
Visual Basic
 1992 - Visual Basic 1 for Windows 3
 Visual Basic 4 - for Windows 95
 Visual Basic 5 - for Office 97
 Visual Basic 6 - for Windows 98 & Office 2000
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 10
Visual Basic Editions
Learning Edition
Professional Edition
Enterprise Edition
Integrated Development Environment (IDE):
 Contains all the tools and features
needed to create, run, and test programs
 It is called integrated because we can
access virtually all of the development
tools that we need from one screen
called an interface.
 The IDE is also commonly referred to
as the design environment, or
the program.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 11
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 12
VB IDE Components
 Major windows
 Form Designer
 Form Layout
 Toolbox
 Project Explorer
 Object Browser
 Properties
 Code Editor
 Immediate, Locals, Watch
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 13
Toolbox
Form
Designer
Window
Code Editor
Window
Project
Explorer
Properties
window
Form Layout
Window
Visual Basic 6 Interactive Development Environment
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 14
VB IDE Components
Title bar: contains tile of the project/file
Menu Bar: contains all commands needed to run VB (File,
Edit, View etc…).
Toolbars: quick access to commonly used menu commands.
Project Explorer: displays the project’s components.
Toolbox: contains icons of the controls that can be placed on
the project’s Forms to create the application’s interface.
Properties Window: Shows the property settings of the
selected control (size, caption, color, etc…).
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 15
VB IDE Components
Code Window : The place where the code is written is Code
Window. To open the code window of a particular object,
just double click on that object.
Form Layout Window :Using this window we can position
forms as we want them to appear on the screen.
Form Designer window: These are just windows in which a
particular form appears. We can place objects on a form by
double clicking on them.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 16
VB IDE Components (Tool box)
Control Description
Pointer Provides a way to move and resize the controls form
PictureBox Displays icons/bitmaps and metafiles. It displays text or acts as a visual container for other controls.
TextBox Used to display message and enter text.
Frame Serves as a visual and functional container for controls
CommandButton Used to carry out the specified action when the user chooses it.
CheckBox Displays a True/False or Yes/No option.
OptionButton OptionButton control which is a part of an option group allows the user to select only one option even it displays mulitiple choices.
ListBox Displays a list of items from which a user can select one.
ComboBox Contains a TextBox and a ListBox. This allows the user to select an ietm from the dropdown ListBox, or to type in a selection in the TextBox.
HScrollBar and VScrollBar These controls allow the user to select a value within the specified range of values
Timer Executes the timer events at specified intervals of time
DriveListBox Displays the valid disk drives and allows the user to select one of them.
DirListBox Allows the user to select the directories and paths, which are displayed.
FileListBox Displays a set of files from which a user can select the desired one.
Shape Used to add shape (rectangle, square or circle) to a Form
Line Used to draw straight line to the Form
Image used to display images such as icons, bitmaps and metafiles. But less capability than the PictureBox
Data Enables the use to connect to an existing database and display information from it.
OLE Used to link or embed an object, display and manipulate data from other windows based applications.
Label Displays a text that the user cannot modify or interact with.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 17
VB IDE Components(project window)
 The Project
Window displays a
list of all forms and
modules making up
your application.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 18
VB IDE Components(property window)
Properties Window :
 This is the place where we set the
object’s properties.
 Ex : caption of a form or a command
button , text of a textbox
etc.
 When we select an object, the
corresponding object’s properties will
appear in the properties window as
shown in above figure.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 19
VB IDE Components(form design
window)
Form design window:
 These are just windows in
which a particular form
appears.
 We can place objects on a
form by double clicking on
them.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 20
VB IDE Components(code window)
Code Window :
 The place where the code is written is
Code Window.
 To open the code window of a particular
object, just double click on that object.
 There are two drop-down list boxes in
the code window.
1. Light list box lets to select the
object to add code into.
2. Right list box lets to select the
procedures to add all the methods the object
control supports.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 21
VB IDE Components(form layout
window)
Form Layout Window :
 Using this window we can
position forms as we want them
to appear on the screen.
 For positioning the form , drag
the form on form layout
window to the required new
location.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 22
Features of Visual Basic
 Lots of icons and pictures for your use
 Response to mouse and keyboard actions
 Clipboard and printer access
 Full array of mathematical, string handling, and
graphics functions
 Can handle fixed and dynamic variable and control
arrays
 Sequential and random access file support
 Useful debugger and error-handling facilities
 Powerful database access tools
 ActiveX support
 Package & Deployment Wizard makes distributing
your applications simple
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 23
Visual Basic operates in three
modes.
Design mode - used to build application
Run mode - used to run the application
Break mode - application halted and debugger is
available
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 24
Steps in Developing Application
There are three primary steps involved in building a
Visual Basic application:
1. Create the user interface
2. Assign properties to controls
3. Attach code to controls
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 25
Step 1:Create the user interface
 Choose needed controls in Toolbox, drag it and drop it on the form at
the required location.
 Creating controls on vb:
In two ways we can add controls to vb form
1. Double click
• We can place controls By double clicking the control on the tool box
(default size of the selected control will be displayed on the form design
window)
• it is created with a default size on the form.
• You can then move it or resize it.
2. Drag and drop
Using drag and drop method we can resize selected control by clicking and
dragging the mouse
Click the tool in the toolbox, then move the mouse pointer to the form
window. The cursor changes to a crosshair. Place the crosshair at the upper
left corner of where you want the control to be, press the left mouse button
and hold it down while dragging the cursor toward the lower right corner.
When you release the mouse button, the control is drawn
To move a control you have drawn,
click the object in the form window
and drag it to the new location.
Release the mouse button.
To resize a control, click the object
so that it is select and sizing handles
appear. Use these handles to resize
the object.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 26
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 27
Step 2: Changing properties
 Once the required controls are placed on the form,
we have to change the properties of the control to
get the required look and behavior.
 Each control has a collection of properties.
 Each property represents an attribute of the control.
For example, Name property identifies the name
used to reference the control in the code and so on
 So to change the properties of control as needed
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 28
Step 3: Attach code to
controls
Write code on code window
The Visual Basic Code consists of
statements, and declarations.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 29
creating controls
We can create many controls
Some of the controls are listed
below:
image controls – command buttons –
text boxes – message boxes –list
boxes – combo boxes.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 30
creating controls (command buttons )
 It is probably the most widely used control.
 It is used to begin, interrupt, or end a particular process.
Command Button Properties:
 Appearance - Selects 3-D or flat appearance.
 Caption - String to be displayed on button.
 Default Allows selection of button with Enter key (only one
button on a form can have this property True).
 Font Sets font type, style, size.
Command Button Events:
 Click Event – it is the widely used event on command button
it triggered when button is selected either by clicking on it or
by pressing the access key.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 31
creating controls (text boxes )
 A text box is used to display information
 We can enter information at design time, by a user at
runtime, or assigned within code.
 The displayed text may be edited.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 32
Access keys
 An access key is an underlined character in the text of a
menu, menu item, or the label of a control such as a button.
 With an access key, the user can "click" a button by pressing
the Alt key in combination with the predefined key
 Eg: File Edit Format
 The underscored characters are access keys
 & symbol is used to specify the access key character.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 33
Editing tools
 The Edit toolbar provides shortcuts to commonly used menu
items. These items are frequently used when editing code:

VBA/VB6 Edit Toolbar
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 34
ComboBox
 A ComboBox combines the features of a TextBox and a
ListBox.
 This enables the user to select either by typing text into
the ComboBox or by selecting an item from the list.
 There are three types of ComboBox styles that are
represented as shown below.
1. Dropdown Combo (style 0)
2. Simple Combo (style 1)
3. Dropdown List (style 2)
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 35
Combo Box
Simple Combo (style 1)
It displays the contents of its list all the time. The user can
select an item from the list or type an item in the edit portion
of the combo box.
Dropdown Combo (style 0)
first appears as only an edit area with a down arrow button at
the right. The list portion stays hidden until the user clicks the
down-arrow button. The user can either select a value from the
list or type a value in the edit area.
Dropdown List combo (style 2)
The user can only select an item and cannot type anything in
the edit area. Anyway this area displays the selected item.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 36
Variables
 Variables are used by Visual Basic to hold information
needed by your application.
 The value of the variable will change during the execution of
a program
 The variable are used to store the value temporally in
memory location
Rules used in naming variables:
 No more than 40 characters
 They may include letters, numbers, and underscore (_)
 The first character must be a letter
 You cannot use a reserved word (word needed by Visual
Basic)
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 37
Visual Basic Data Types
 VB SUPPORTS THE FOLLOWING FUNDAMENDAL DATA
TYPES:
1. Numeric 2. String 3. Date 4. Boolean 5. Variant
Numeric
Byte Store integer values in the range of 0 - 255
Integer Store integer values in the range of (-32,768) - (+ 32,767)
Long Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468)
Single Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038)
Double Store large floating value which exceeding the single data type value
Currency store monetary values. It supports 4 digits to the right of decimal point and 15 digits to the left
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 38
Visual Basic Data Types
2. String
 Use to store alphanumeric values. A variable length string can store
approximately 4 billion characters
3.Date
 Use to store date and time values.
 A variable declared as date type can store both date and time
values
 it can store date values 01/01/0100 up to 12/31/9999
4. Boolean
 Boolean data types hold either a true or false value. Values are
internally stored as -1 (True) and 0 (False)
5. Variant
 Stores any type of data and is the default Visual Basic data type.
In Visual Basic if we declare a variable without any data type by
default the data type is assigned as default.
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 39
Type declaration characters:
 VB SUPPORTS THE FOLLOWING Type Declaration
Characters
 One way to define any variables to use some special
symbol called type declaration character inside using the
data type names.
Data Type Type Declaration Character
String $
Integer %
Long &
Single !
Double #
Currency @
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 40
Variable Declaration
 There are three ways for a variable to be typed (declared):
1. Default
2. Implicit
3. Explicit
Default
 If variables are not implicitly or explicitly declared , they are assigned the
variant type by default.
 The variant data type is a special type used by Visual Basic that can contain
numeric, string, or date data.
 Eg: Dim vntWhatever As Variant
Dim vntWhatever
.)
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 41
Variable Declaration
explicit
 use the corresponding suffix shown above in the
data type table. For example,
 TextValue$ = "This is a string“ (creates a string
variable)
 Amount% = 300 ( creates an integer variable
 Dim intCounter As Integer
Dim intCounter%
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 42
Variable Declaration
 Implicit vs Explicit Declaration
 dim x 'implicit
 dim x as integer 'explicit
 syntax for declaring a variable in VB :
 [Dim Private | Public | Static |
Global] variablename [As datatype]
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 43
Scope of Variable
 There are three levels of scope:
 project-level (also called "global" or "application" scope) the
variable is accessible to all procedures in all modules of the
project.
 module-level - the variable is accessible to all procedures in the
module in which it is declared
 local-level - the variable is accessible only to the procedure in
which it is declared
 Multiple Declarations on One Line
 VB allows you to declare any number of variables on one line
 Dim A, B, C As Integer

Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 44
Constants
It is a space in memory filled with
fixed value that will not be changed.
Constant may be declared as:
Const constant name = value
EG:
Const p = 3.14159
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 45
Inputting variables
There are methods to input variable x
as stated in the following:
To enter many variables we usually
use the second method with loop
Method of input For all type of variable
text tool X=textno.text
input box X=inputbox("prompt","title"
)
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 46
Outputting variables
There are methods to output variable
x as stated in the following:
Method of output For all type of variable
On form Print x (in load event we
must use this statement)
to text tool textno.text =X
to label tool Labelno.caption=x
By message box msgbox (x)
Or msgbox ("remark"& x)
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 47
Displaying information on a
form
 To display information on a form print statement is used.
 The instruction print could be very helpful to display data
and used as follows:
Code Description example
print To leave one line and
print on next
Print "a", "b",
"c"
Use (,) to print a
distance
between outputs
a b c
Print "a"; "b";
"c"
Use (;) to print the
outputs adjacent
abc
Print "a","b";
Print "c"
Print a, b then print c
on
the same line
abc
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 48
String Manipulation Functions
1. Len Function
The Len function returns an integer value which is the
length of a phrase or a sentence, including the empty spaces.
Syntax:
 Len (“Phrase”)
EG:
Len (“VisualBasic”) = 11
Len (“welcome to VB tutorial”) = 22
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 49
String Manipulation Functions
2.The Right Function
 The Right function extracts the right portion of a phrase.
syntax:
Right (“Phrase”, n)
 Where n is the starting position from the right of the
phrase where the portion of the phrase is going to be
extracted
example,
 Right(“Visual Basic”, 4) = asic
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 50
String Manipulation Functions
3. The Left Function
 The Left function extract the left portion of a
phrase.
syntax:
Left(“Phrase”, n)
 Where n is the starting position from the left of
the phase where the portion of the phrase is going
to be extracted.
example,
 Left (“Visual Basic”, 4) = Visu
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 51
String Manipulation Functions
4. The Ltrim Function
 The Ltrim function trims the empty spaces of the left portion of the phrase. syntax is
 Ltrim(“Phrase”)
 example,
 Ltrim (“ Visual Basic”, 4)= Visual basic
5.The Rtrim Function
 The Rtrim function trims the empty spaces of the right portion of the phrase. The syntax
is
 Rtrim(“Phrase”)
 example,
 Rtrim (“Visual Basic ”, 4) = Visual basic
6.The Trim function
 The Trim function trims the empty spaces on both side of the phrase. The syntax is
 Trim(“Phrase”)
 example,
 Trim (“ Visual Basic ”) = Visual basic
Exploring MS Visual
Basic 6
Copyright 1999 Prentice-Hall, Inc. 52
String Manipulation Functions
7. The Mid Function
 The Mid function extracts a substring from the original phrase or string. It takes the
following format:
 Mid(phrase, position, n)
 Where position is the starting position of the phrase from which the extraction process
will start and n is the number of characters to be extracted. For example,
 Mid(“Visual Basic”, 3, 6) = ual Ba
8. The Ucase and the Lcase functions
 The Ucase function converts all the characters of a string to capital letters. On the other
hand, the Lcase function converts all the characters of a string to small letters. For
example,
 Ucase(“Visual Basic”) =VISUAL BASIC
 Lcase(“Visual Basic”) =visual basic
10. THE CHR AND ASC FUNCTIONS:
 Chr(charcode)
 and the syntax of the Asc function is
 Asc(Character)
 The following are some examples:
 Chr(65)=A, Chr(122)=z, Chr(37)=% , Asc(“B”)=66, Asc(“&”)=38

More Related Content

Similar to VB6_INTRODUCTION.ppt

Future Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual BasicFuture Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual Basicijtsrd
 
vb-160518151614.pdf
vb-160518151614.pdfvb-160518151614.pdf
vb-160518151614.pdfLimEchYrr
 
vb-160518151614.pptx
vb-160518151614.pptxvb-160518151614.pptx
vb-160518151614.pptxLimEchYrr
 
Login Project with introduction .pptx
Login Project with introduction .pptxLogin Project with introduction .pptx
Login Project with introduction .pptxkulmiyealiabdille
 
Vb6.0 Introduction
Vb6.0 IntroductionVb6.0 Introduction
Vb6.0 IntroductionTennyson
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic classall
 
Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)Mark Vincent Cantero
 
VB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfVB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfAdiseshaK
 
Class viii ch-7 visual basic 2008
Class  viii ch-7 visual basic 2008Class  viii ch-7 visual basic 2008
Class viii ch-7 visual basic 2008jessandy
 
introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxclassall
 

Similar to VB6_INTRODUCTION.ppt (20)

Meaning Of VB
Meaning Of VBMeaning Of VB
Meaning Of VB
 
Vb 6ch123
Vb 6ch123Vb 6ch123
Vb 6ch123
 
Future Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual BasicFuture Scope in Application Developement of Visual Basic
Future Scope in Application Developement of Visual Basic
 
vb.pptx
vb.pptxvb.pptx
vb.pptx
 
vb-160518151614.pdf
vb-160518151614.pdfvb-160518151614.pdf
vb-160518151614.pdf
 
vb-160518151614.pptx
vb-160518151614.pptxvb-160518151614.pptx
vb-160518151614.pptx
 
Login Project with introduction .pptx
Login Project with introduction .pptxLogin Project with introduction .pptx
Login Project with introduction .pptx
 
Vb unit t 1.1
Vb unit t 1.1Vb unit t 1.1
Vb unit t 1.1
 
Visual basic
Visual basicVisual basic
Visual basic
 
Vb.net ide
Vb.net ideVb.net ide
Vb.net ide
 
unit 4.docx
unit 4.docxunit 4.docx
unit 4.docx
 
Ch02 bronson
Ch02 bronsonCh02 bronson
Ch02 bronson
 
Vb6.0 Introduction
Vb6.0 IntroductionVb6.0 Introduction
Vb6.0 Introduction
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic
 
Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)
 
VB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdfVB PPT by ADI part-1.pdf
VB PPT by ADI part-1.pdf
 
Class viii ch-7 visual basic 2008
Class  viii ch-7 visual basic 2008Class  viii ch-7 visual basic 2008
Class viii ch-7 visual basic 2008
 
introduction to visual basic PPT.pptx
introduction to visual basic PPT.pptxintroduction to visual basic PPT.pptx
introduction to visual basic PPT.pptx
 
Visual basic
Visual basic Visual basic
Visual basic
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 

More from BhuvanaR13

CRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdfCRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdfBhuvanaR13
 
Linux File System.docx
Linux File System.docxLinux File System.docx
Linux File System.docxBhuvanaR13
 
UNIT I LINUX.docx
UNIT I LINUX.docxUNIT I LINUX.docx
UNIT I LINUX.docxBhuvanaR13
 
networktopology-final.pptx
networktopology-final.pptxnetworktopology-final.pptx
networktopology-final.pptxBhuvanaR13
 
UNIT III_DCN.pdf
UNIT III_DCN.pdfUNIT III_DCN.pdf
UNIT III_DCN.pdfBhuvanaR13
 
UNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdfUNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdfBhuvanaR13
 
UNIT I_DCN.pdf
UNIT I_DCN.pdfUNIT I_DCN.pdf
UNIT I_DCN.pdfBhuvanaR13
 
INTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptxINTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptxBhuvanaR13
 
VB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptVB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptBhuvanaR13
 
VB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.pptVB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.pptBhuvanaR13
 

More from BhuvanaR13 (10)

CRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdfCRYPTOGRAPHY (2).pdf
CRYPTOGRAPHY (2).pdf
 
Linux File System.docx
Linux File System.docxLinux File System.docx
Linux File System.docx
 
UNIT I LINUX.docx
UNIT I LINUX.docxUNIT I LINUX.docx
UNIT I LINUX.docx
 
networktopology-final.pptx
networktopology-final.pptxnetworktopology-final.pptx
networktopology-final.pptx
 
UNIT III_DCN.pdf
UNIT III_DCN.pdfUNIT III_DCN.pdf
UNIT III_DCN.pdf
 
UNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdfUNIT 2_DCN-converted.pdf
UNIT 2_DCN-converted.pdf
 
UNIT I_DCN.pdf
UNIT I_DCN.pdfUNIT I_DCN.pdf
UNIT I_DCN.pdf
 
INTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptxINTRODUCTION TO MOBILE COMPUTING.pptx
INTRODUCTION TO MOBILE COMPUTING.pptx
 
VB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.pptVB_ERROR CONTROL_FILE HANDLING.ppt
VB_ERROR CONTROL_FILE HANDLING.ppt
 
VB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.pptVB6_OBJECTS AND GRAPHICS.ppt
VB6_OBJECTS AND GRAPHICS.ppt
 

Recently uploaded

50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfjoachimlavalley1
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptxJosvitaDsouza2
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxRaedMohamed3
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxssuserbdd3e8
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 

Recently uploaded (20)

50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 

VB6_INTRODUCTION.ppt

  • 1. Chapter 1 Introduction to Visual Basic 1 R. BHUVANESWARI ASST.PROFESSOR DEPT OF COMPUTER SCIENCE AND APPLICATION DKM COLLEGE FOR WOMEN (AUTONOMOUS) VELLORE
  • 2. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 2 Objectives  Machine language vs.. High-level language  Procedure-oriented, object-oriented, and event-driven languages  Background of Visual Basic  VB Integrated Development Environment  Online documentation and Help features
  • 3. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 3 Application Programs Program - detailed set of instructions for a computer to execute Application programs (applications or apps) - self-contained collection of programs that perform a task for the end user Programming language - formal language used to give instructions to computers
  • 4. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 4 History of Programming Languages Machine language Procedure-oriented languages Object-oriented languages Event-driven languages Natural languages
  • 5. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 5 History of Programming Languages Machine Language  different for each computer processor  Procedure-Oriented Languages  FORTRAN  COBOL  Pascal  C  Ada
  • 6. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 6 History of Programming Languages Object-oriented languages  Smalltalk  C++  Ada 95 Event-driven languages  Visual Basic  most Visual languages
  • 7. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 7 History of Programming Languages Natural languages  computer will accept a user’s native or natural language, such as English  Researchers continue to work in this area
  • 8. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 8 Background of Visual Basic BASIC  Beginner’s All-purpose Symbolic Instruction Code  By John Kemeny and Thomas Kurtz  Designed to teach programming to beginners  BASIC language interpreter, one of Microsoft’s first products
  • 9. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 9 Background of Visual Basic BASIC – (Beginners' All-purpose Symbolic Instruction Code)  Included with DOS  QBASIC - included with DOS Version 5 - subset of BASIC Visual Basic  1992 - Visual Basic 1 for Windows 3  Visual Basic 4 - for Windows 95  Visual Basic 5 - for Office 97  Visual Basic 6 - for Windows 98 & Office 2000
  • 10. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 10 Visual Basic Editions Learning Edition Professional Edition Enterprise Edition
  • 11. Integrated Development Environment (IDE):  Contains all the tools and features needed to create, run, and test programs  It is called integrated because we can access virtually all of the development tools that we need from one screen called an interface.  The IDE is also commonly referred to as the design environment, or the program. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 11
  • 12. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 12 VB IDE Components  Major windows  Form Designer  Form Layout  Toolbox  Project Explorer  Object Browser  Properties  Code Editor  Immediate, Locals, Watch
  • 13. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 13 Toolbox Form Designer Window Code Editor Window Project Explorer Properties window Form Layout Window Visual Basic 6 Interactive Development Environment
  • 14. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 14 VB IDE Components Title bar: contains tile of the project/file Menu Bar: contains all commands needed to run VB (File, Edit, View etc…). Toolbars: quick access to commonly used menu commands. Project Explorer: displays the project’s components. Toolbox: contains icons of the controls that can be placed on the project’s Forms to create the application’s interface. Properties Window: Shows the property settings of the selected control (size, caption, color, etc…).
  • 15. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 15 VB IDE Components Code Window : The place where the code is written is Code Window. To open the code window of a particular object, just double click on that object. Form Layout Window :Using this window we can position forms as we want them to appear on the screen. Form Designer window: These are just windows in which a particular form appears. We can place objects on a form by double clicking on them.
  • 16. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 16 VB IDE Components (Tool box) Control Description Pointer Provides a way to move and resize the controls form PictureBox Displays icons/bitmaps and metafiles. It displays text or acts as a visual container for other controls. TextBox Used to display message and enter text. Frame Serves as a visual and functional container for controls CommandButton Used to carry out the specified action when the user chooses it. CheckBox Displays a True/False or Yes/No option. OptionButton OptionButton control which is a part of an option group allows the user to select only one option even it displays mulitiple choices. ListBox Displays a list of items from which a user can select one. ComboBox Contains a TextBox and a ListBox. This allows the user to select an ietm from the dropdown ListBox, or to type in a selection in the TextBox. HScrollBar and VScrollBar These controls allow the user to select a value within the specified range of values Timer Executes the timer events at specified intervals of time DriveListBox Displays the valid disk drives and allows the user to select one of them. DirListBox Allows the user to select the directories and paths, which are displayed. FileListBox Displays a set of files from which a user can select the desired one. Shape Used to add shape (rectangle, square or circle) to a Form Line Used to draw straight line to the Form Image used to display images such as icons, bitmaps and metafiles. But less capability than the PictureBox Data Enables the use to connect to an existing database and display information from it. OLE Used to link or embed an object, display and manipulate data from other windows based applications. Label Displays a text that the user cannot modify or interact with.
  • 17. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 17 VB IDE Components(project window)  The Project Window displays a list of all forms and modules making up your application.
  • 18. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 18 VB IDE Components(property window) Properties Window :  This is the place where we set the object’s properties.  Ex : caption of a form or a command button , text of a textbox etc.  When we select an object, the corresponding object’s properties will appear in the properties window as shown in above figure.
  • 19. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 19 VB IDE Components(form design window) Form design window:  These are just windows in which a particular form appears.  We can place objects on a form by double clicking on them.
  • 20. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 20 VB IDE Components(code window) Code Window :  The place where the code is written is Code Window.  To open the code window of a particular object, just double click on that object.  There are two drop-down list boxes in the code window. 1. Light list box lets to select the object to add code into. 2. Right list box lets to select the procedures to add all the methods the object control supports.
  • 21. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 21 VB IDE Components(form layout window) Form Layout Window :  Using this window we can position forms as we want them to appear on the screen.  For positioning the form , drag the form on form layout window to the required new location.
  • 22. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 22 Features of Visual Basic  Lots of icons and pictures for your use  Response to mouse and keyboard actions  Clipboard and printer access  Full array of mathematical, string handling, and graphics functions  Can handle fixed and dynamic variable and control arrays  Sequential and random access file support  Useful debugger and error-handling facilities  Powerful database access tools  ActiveX support  Package & Deployment Wizard makes distributing your applications simple
  • 23. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 23 Visual Basic operates in three modes. Design mode - used to build application Run mode - used to run the application Break mode - application halted and debugger is available
  • 24. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 24 Steps in Developing Application There are three primary steps involved in building a Visual Basic application: 1. Create the user interface 2. Assign properties to controls 3. Attach code to controls
  • 25. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 25 Step 1:Create the user interface  Choose needed controls in Toolbox, drag it and drop it on the form at the required location.  Creating controls on vb: In two ways we can add controls to vb form 1. Double click • We can place controls By double clicking the control on the tool box (default size of the selected control will be displayed on the form design window) • it is created with a default size on the form. • You can then move it or resize it. 2. Drag and drop Using drag and drop method we can resize selected control by clicking and dragging the mouse Click the tool in the toolbox, then move the mouse pointer to the form window. The cursor changes to a crosshair. Place the crosshair at the upper left corner of where you want the control to be, press the left mouse button and hold it down while dragging the cursor toward the lower right corner. When you release the mouse button, the control is drawn
  • 26. To move a control you have drawn, click the object in the form window and drag it to the new location. Release the mouse button. To resize a control, click the object so that it is select and sizing handles appear. Use these handles to resize the object. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 26
  • 27. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 27 Step 2: Changing properties  Once the required controls are placed on the form, we have to change the properties of the control to get the required look and behavior.  Each control has a collection of properties.  Each property represents an attribute of the control. For example, Name property identifies the name used to reference the control in the code and so on  So to change the properties of control as needed
  • 28. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 28 Step 3: Attach code to controls Write code on code window The Visual Basic Code consists of statements, and declarations.
  • 29. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 29 creating controls We can create many controls Some of the controls are listed below: image controls – command buttons – text boxes – message boxes –list boxes – combo boxes.
  • 30. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 30 creating controls (command buttons )  It is probably the most widely used control.  It is used to begin, interrupt, or end a particular process. Command Button Properties:  Appearance - Selects 3-D or flat appearance.  Caption - String to be displayed on button.  Default Allows selection of button with Enter key (only one button on a form can have this property True).  Font Sets font type, style, size. Command Button Events:  Click Event – it is the widely used event on command button it triggered when button is selected either by clicking on it or by pressing the access key.
  • 31. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 31 creating controls (text boxes )  A text box is used to display information  We can enter information at design time, by a user at runtime, or assigned within code.  The displayed text may be edited.
  • 32. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 32 Access keys  An access key is an underlined character in the text of a menu, menu item, or the label of a control such as a button.  With an access key, the user can "click" a button by pressing the Alt key in combination with the predefined key  Eg: File Edit Format  The underscored characters are access keys  & symbol is used to specify the access key character.
  • 33. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 33 Editing tools  The Edit toolbar provides shortcuts to commonly used menu items. These items are frequently used when editing code:  VBA/VB6 Edit Toolbar
  • 34. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 34 ComboBox  A ComboBox combines the features of a TextBox and a ListBox.  This enables the user to select either by typing text into the ComboBox or by selecting an item from the list.  There are three types of ComboBox styles that are represented as shown below. 1. Dropdown Combo (style 0) 2. Simple Combo (style 1) 3. Dropdown List (style 2)
  • 35. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 35 Combo Box Simple Combo (style 1) It displays the contents of its list all the time. The user can select an item from the list or type an item in the edit portion of the combo box. Dropdown Combo (style 0) first appears as only an edit area with a down arrow button at the right. The list portion stays hidden until the user clicks the down-arrow button. The user can either select a value from the list or type a value in the edit area. Dropdown List combo (style 2) The user can only select an item and cannot type anything in the edit area. Anyway this area displays the selected item.
  • 36. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 36 Variables  Variables are used by Visual Basic to hold information needed by your application.  The value of the variable will change during the execution of a program  The variable are used to store the value temporally in memory location Rules used in naming variables:  No more than 40 characters  They may include letters, numbers, and underscore (_)  The first character must be a letter  You cannot use a reserved word (word needed by Visual Basic)
  • 37. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 37 Visual Basic Data Types  VB SUPPORTS THE FOLLOWING FUNDAMENDAL DATA TYPES: 1. Numeric 2. String 3. Date 4. Boolean 5. Variant Numeric Byte Store integer values in the range of 0 - 255 Integer Store integer values in the range of (-32,768) - (+ 32,767) Long Store integer values in the range of (- 2,147,483,468) - (+ 2,147,483,468) Single Store floating point value in the range of (-3.4x10-38) - (+ 3.4x1038) Double Store large floating value which exceeding the single data type value Currency store monetary values. It supports 4 digits to the right of decimal point and 15 digits to the left
  • 38. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 38 Visual Basic Data Types 2. String  Use to store alphanumeric values. A variable length string can store approximately 4 billion characters 3.Date  Use to store date and time values.  A variable declared as date type can store both date and time values  it can store date values 01/01/0100 up to 12/31/9999 4. Boolean  Boolean data types hold either a true or false value. Values are internally stored as -1 (True) and 0 (False) 5. Variant  Stores any type of data and is the default Visual Basic data type. In Visual Basic if we declare a variable without any data type by default the data type is assigned as default.
  • 39. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 39 Type declaration characters:  VB SUPPORTS THE FOLLOWING Type Declaration Characters  One way to define any variables to use some special symbol called type declaration character inside using the data type names. Data Type Type Declaration Character String $ Integer % Long & Single ! Double # Currency @
  • 40. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 40 Variable Declaration  There are three ways for a variable to be typed (declared): 1. Default 2. Implicit 3. Explicit Default  If variables are not implicitly or explicitly declared , they are assigned the variant type by default.  The variant data type is a special type used by Visual Basic that can contain numeric, string, or date data.  Eg: Dim vntWhatever As Variant Dim vntWhatever .)
  • 41. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 41 Variable Declaration explicit  use the corresponding suffix shown above in the data type table. For example,  TextValue$ = "This is a string“ (creates a string variable)  Amount% = 300 ( creates an integer variable  Dim intCounter As Integer Dim intCounter%
  • 42. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 42 Variable Declaration  Implicit vs Explicit Declaration  dim x 'implicit  dim x as integer 'explicit  syntax for declaring a variable in VB :  [Dim Private | Public | Static | Global] variablename [As datatype]
  • 43. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 43 Scope of Variable  There are three levels of scope:  project-level (also called "global" or "application" scope) the variable is accessible to all procedures in all modules of the project.  module-level - the variable is accessible to all procedures in the module in which it is declared  local-level - the variable is accessible only to the procedure in which it is declared  Multiple Declarations on One Line  VB allows you to declare any number of variables on one line  Dim A, B, C As Integer 
  • 44. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 44 Constants It is a space in memory filled with fixed value that will not be changed. Constant may be declared as: Const constant name = value EG: Const p = 3.14159
  • 45. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 45 Inputting variables There are methods to input variable x as stated in the following: To enter many variables we usually use the second method with loop Method of input For all type of variable text tool X=textno.text input box X=inputbox("prompt","title" )
  • 46. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 46 Outputting variables There are methods to output variable x as stated in the following: Method of output For all type of variable On form Print x (in load event we must use this statement) to text tool textno.text =X to label tool Labelno.caption=x By message box msgbox (x) Or msgbox ("remark"& x)
  • 47. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 47 Displaying information on a form  To display information on a form print statement is used.  The instruction print could be very helpful to display data and used as follows: Code Description example print To leave one line and print on next Print "a", "b", "c" Use (,) to print a distance between outputs a b c Print "a"; "b"; "c" Use (;) to print the outputs adjacent abc Print "a","b"; Print "c" Print a, b then print c on the same line abc
  • 48. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 48 String Manipulation Functions 1. Len Function The Len function returns an integer value which is the length of a phrase or a sentence, including the empty spaces. Syntax:  Len (“Phrase”) EG: Len (“VisualBasic”) = 11 Len (“welcome to VB tutorial”) = 22
  • 49. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 49 String Manipulation Functions 2.The Right Function  The Right function extracts the right portion of a phrase. syntax: Right (“Phrase”, n)  Where n is the starting position from the right of the phrase where the portion of the phrase is going to be extracted example,  Right(“Visual Basic”, 4) = asic
  • 50. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 50 String Manipulation Functions 3. The Left Function  The Left function extract the left portion of a phrase. syntax: Left(“Phrase”, n)  Where n is the starting position from the left of the phase where the portion of the phrase is going to be extracted. example,  Left (“Visual Basic”, 4) = Visu
  • 51. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 51 String Manipulation Functions 4. The Ltrim Function  The Ltrim function trims the empty spaces of the left portion of the phrase. syntax is  Ltrim(“Phrase”)  example,  Ltrim (“ Visual Basic”, 4)= Visual basic 5.The Rtrim Function  The Rtrim function trims the empty spaces of the right portion of the phrase. The syntax is  Rtrim(“Phrase”)  example,  Rtrim (“Visual Basic ”, 4) = Visual basic 6.The Trim function  The Trim function trims the empty spaces on both side of the phrase. The syntax is  Trim(“Phrase”)  example,  Trim (“ Visual Basic ”) = Visual basic
  • 52. Exploring MS Visual Basic 6 Copyright 1999 Prentice-Hall, Inc. 52 String Manipulation Functions 7. The Mid Function  The Mid function extracts a substring from the original phrase or string. It takes the following format:  Mid(phrase, position, n)  Where position is the starting position of the phrase from which the extraction process will start and n is the number of characters to be extracted. For example,  Mid(“Visual Basic”, 3, 6) = ual Ba 8. The Ucase and the Lcase functions  The Ucase function converts all the characters of a string to capital letters. On the other hand, the Lcase function converts all the characters of a string to small letters. For example,  Ucase(“Visual Basic”) =VISUAL BASIC  Lcase(“Visual Basic”) =visual basic 10. THE CHR AND ASC FUNCTIONS:  Chr(charcode)  and the syntax of the Asc function is  Asc(Character)  The following are some examples:  Chr(65)=A, Chr(122)=z, Chr(37)=% , Asc(“B”)=66, Asc(“&”)=38

Editor's Notes

  1. Exploring Microsoft Visual Basic 6.0