SlideShare ist ein Scribd-Unternehmen logo
1 von 42
A. JOSEPHINE, M.C.A.,M.Phil.,
Asst.Professor
E.M.G.Yadava Women’s College,
Madurai
1
Objectives
 Understand the benefits of using Microsoft Visual Basic 6.0 for
Windows as an application tool.
 Understand the Visual Basic event-driven programming
concepts, terminology, and available tools.
 Learn the fundamentals of designing, implementing, and
distributing a Visual Basic application.
 Learn to use the Visual Basic toolbox.
 Learn to modify object properties.
 Learn object methods.
 Use the menu design window.
 Understand proper debugging and error-handling procedures.
 Gain a basic understanding of database access and
management using data bound controls.
 Obtain an introduction to ActiveX controls and the Windows
Application Programming Interface (API).
2
What is Visual Basic?
 Visual Basic
Is a tool that allows you to develop Windows (Graphic
User Interface - GUI) applications. The applications
have a familiar appearance to the user.
3
What is Visual Basic?
 Visual Basic is event-driven, meaning
code remains idle until called upon to
respond to some event (button pressing,
menu selection, ...). Visual Basic is
governed by an event processor.
Nothing happens until an event is
detected. Once an event is detected, the
code corresponding to that event (event
procedure) is executed. Program control
is then returned to the event processor.
4
Some Features of Visual Basic
 Full set of objects - you 'draw' the application
 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
5
Structure of a Visual Basic Application
6
Get back to
Contents
Structure (continued)
7
Form
Control
Button
Window
Get back to
Contents
8
Frame
Option Button
Label
Window
Form
Structure (continued)
Command Button
Get back to
Contents
The code window
9
Contents of thE application (the
Project)
 Forms - Windows that you create for user interface
 Controls - Graphical features drawn on forms to allow user
interaction (text boxes, labels, scroll bars, command buttons,
etc.) Forms and Controls are objects.)
 Properties - Every characteristic of a form or control is specified
by a property. Example properties include names, captions, size,
color, position, and contents. Visual Basic applies default
properties. You can change properties at design time or run time.
 Methods - Built-in procedure that can be invoked to impart some
action to a particular object.
 Event Procedures - Code related to some object. This is the
code that is executed when a certain event occurs.
 General Procedures - Code not related to objects. This code
must be invoked by the application.
 Modules - Collection of general procedures, variable
declarations, and constant definitions used by application.
10
User Interface
11
Main
Window
Tool
Box
Project
Explorer
Properties
Window
Form
Layout
Project
Window
Main Window
 The Main Window consists of the title bar, menu bar,
and toolbar.
12
Start Visual Basic 6.0
13
14
Contents of the Main Window
15
The menu bar has drop-down menus from which you control the operation of the Visual
Basic environment.
The toolbar has buttons that provide shortcuts to some of the menu options.
16
Add
project
Add
form
Menu
editor
Open
project
Save
project
Code editor
tasks
Run
Pause
Stop
Project
explorer
Properties
window
Form
layout
window
Object
browser
Data view
window
Visual
component
manager
Toolbox
Toolbox
17
18
The Properties Window is used to establish initial property values for objects. The
drop-down box at the top of the window lists all objects in the current form. Two views
are available: Alphabetic and Categorized. Under this box are the available properties
for the currently selected object.
The Form Layout Window shows where (upon program execution)
your form will be displayed relative to your monitor’s screen:
19
The Project Window displays a list of all forms
and modules making up your application. You
can also obtain a view of the Form or Code
windows (window containing the actual Basic
coding) from the Project window.
Example: Stopwatch application
The application is used to calculate the time
elapsed between two events. The user starts a
timer, once the second event tops, the user
stops the timer, the time duration is displayed.
The steps are:
1. Drawing controls
2. Setting properties of the controls
3. Writing code
20
1. Drawing Controls
1. Start new project
2. Draw 3 command buttons on the form
3. Draw 6 labels on the form
21
2. Setting properties of the controls
The properties of the controls can be modified in two different
ways:
 Setting properties during design time.
In this way you click on the object (form or control) in the form
window, then click on the Properties Window or the
Properties Window button in the tool bar.
 Setting properties during run time. In this way you can set or
modify properties while your application is running. To do
this, you must write some code. The code format is:
ObjectName.Property = NewValue
Such a format is referred to as dot notation.
For example, to change the BackColor property of a form
name frmStart, you may type:
frmStart.BackColor = BLUE
22
Setting properties during design time
 Here we selected the form window and
clicked on the properties window.
Notice that the from name here (which
is the most important property) is
frmStopWatch.
 Object names can be up to 40
characters long, must start with a letter,
must contain only letters, numbers, and
the underscore (_) character.
23
Setting Properties in stopwatch example
The following table shows the properties you are going to change for
the objects you put on the form.
24
Name Caption Border Style
Form1 frmStopWatch Stopwatch Application 1-Fixed Single
Command1 cmdStart &Start Timing
Command2 cmdEnd &End Timing
Command3 cmdExit E&xit
Label1 Start Time
Label2 End Time
Label3 Elapsed Time
Label4 lblStart 1-Fixed Single
Label5 lblEnd 1-Fixed Single
Label6 lblElapsed 1-Fixed Single
Property
Object
Writing Code
 Variable Declaration
 Variables are used by Visual Basic to hold information needed
by the application.
○ Rules used in naming (declaring) variables:
I. No more than 40 characters
II. They may include letters, numbers, and underscore (_)
III. The first character must be a letter
IV. You cannot use a reserved word (word needed by Visual
Basic)
25
Visual Basic Data Types
26
Data Suffix
Boolean None
Integer %
Long (Integer) &
Single (Floating) !
Double (Floating) #
Currency @
Date None
Object None
String
Variant None
Private Sub Command1_Click()
a% = Text1.Text
Text2.Text = a ^ 2
End Sub
27
Private Sub Command1_Click()
Static a As Integer
a = Text1.Text
Text2.Text = a ^ 2
End Sub Implicit declaration of
the variable a.
There are three ways for a variable to be typed (declared):
1. Default
2. Implicit
3. Explicit
If variables are not implicitly or explicitly typed, 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.
Option Explicit
Dim a As Integer
Private Sub Command1_Click()
a = Text1.Text
Text2.Text = a ^ 2
End Sub
Private Sub Command3_Click()
a = Text1.Text
Text3.Text = 2 * a + 5
End Sub
28
Explicit declaration of the
variable a.
Variable Scope
29
Global Declaration of a variable
 For the variable to be declared globally, it
should be declared in a module, to create a
module,
30
How to Create a Module
31
In the module declare the variables by writing the following line:
Global a, b, c As Long
Dim c As Integer
In this way the variables will be kept in the whole code as they
been defined.
The Visual Basic Language
 Visual Basic Statements and Expressions
The simplest statement is the assignment statement. It consists of
a variable name, followed by the assignment operator (=), followed by
some sort of expression.
• StartTime = Now
• Explorer.Caption = "Captain Spaulding"
• BitCount = ByteCount * 8
• Energy = Mass * LIGHTSPEED ^ 2
• NetWorth = Assets – Liabilities
Statements normally take up a single line with no terminator.
Statements can be stacked by using a colon (:) to separate them.
Example:
• StartTime = Now : EndTime = StartTime + 10
32
 Visual Basic Operators
arithmetic operators:
 The simplest operators carry out arithmetic operations. These
operators in their order of precedence are:
Operator Operation
1. ^ Exponentiation
2. * / Multiplication and division
3.  Integer division (truncates)
4. Mod Modulus
5. + - Addition and subtraction
Parentheses around expressions can change precedence.
comparison operators:
Operator Comparison
1. > Greater than
2. < Less than
3. >= Greater than or equal to
4. <= Less than or equal to
5. = Equal to
6. <> Not equal to
The result of a comparison operation is a Boolean value (True or False).
33
logical operators
Operator Operation
1. Not Logical not
2. And Logical and
3. Or Logical or
 The Not operator simply negates an operand.
 The And operator returns a True if both operands are
True else, it returns a False.
 · The Or operator returns a True if either one of its
operands is True, else it returns a False.
Logical operators follow arithmetic operators in
precedence.
34
Visual Basic Functions
Some of the built in visual basic functions are given here for example
35
Function Value returned
Abs Absolute value
Asc ASCII or ANSI code of a character
Chr Character corresponding to a given ASCII or ANSI code
Cos Cosine of an angle
Date Current date as a text string
Format Date or number converted to a text string
Left Selected left side of a text string
Len Number of characters in a text string
Mid Selected portion of a text string
Now Current time and date
Right Selected right end of a text string
Rnd Random number
Sin Sine of an angle
Sqr Square root of a number
Str Number converted to a text string
Time Current time as a text string
Timer Number of seconds elapsed since midnight
Val Numeric value of a given text string
Visual Basic Symbolic Constants
Functions and objects always require data arguments
that affect their operation and return values you want
to read and interpret. These arguments and values
are constant numerical data and difficult to interpret
based on just the numerical value. To make these
constants more understandable, Visual Basic assigns
names to the most widely used values, these are
called
symbolic constants. You can find such constants
here.
36
MsgBox Arguments Constants
37
Constant Value Description
vbOKOnly 0 OK button only (default)
vbOKCancel 1 OK and Cancel buttons.
vbAbortRetryIgnore 2 Abort, Retry, and Ignore buttons.
vbYesNoCancel 3 Yes, No, and Cancel buttons.
vbYesNo 4 Yes and No buttons.
vbRetryCancel 5 Retry and Cancel buttons.
vbCritical 16 Critical message.
vbQuestion 32 Warning query.
vbExclamation 48 Warning message.
vbInformation 64 Information message.
vbDefaultButton1 0 First button is default (default)
vbDefaultButton2 256 Second button is default.
vbDefaultButton3 512 Third button is default.
vbApplicationModal 0 Application modal message box
vbSystemModal 4096 System modal message box.
Example: Temperature conversion
The Fahrenheit temperature is converted into Celsius by
the following formula
The interface should look like shown here
38
9
5
*)32F(C 
Creating File for Editing
A file is being creating for input, output and as file
editor.
1. Create new project
2. On the form draw a textbox as large as the
size of the form
3. Add from the tool box a COMMON DIALOG
BOX. If it is not there, follow the steps below
a. From PROJECT menu select components
b. Scroll the components to MICROSOFT DIALOG
BOX and check the box .
c. It is now on the toolbox bar.
4. Notice its name which you will use in the
code.
5. Now, use from TOOLS the menu editor to
add (file) and (format) menus.
39
File Menu
40
Use the MNUE EDITOR to write the file
menu components.
The code:
•Exit code
Click on exit in the created file menu,
and start writing the code for ending the
run.
'Make sure user really wants to exit
Dim Response As Integer
Response = MsgBox("Are you sure you
want to exit the note editor?", vbYesNo +
vbCritical + vbDefaultButton2, "Exit Editor")
If Response = vbNo Then
Exit Sub
Else
End
End If
• New code
Click on New in the created file menu, and start
writing the code for creating new file.
41
'If user wants new file, clear out text
Dim Response As Integer
Response = MsgBox("Are you sure you want to start a new file?",
vbYesNo + vbQuestion, "New File")
If Response = vbYes Then
txtEdit.Text = ""
Else
End If
• Save code
Click on Save in the created file menu, and start writing the code for
saving the created file with extension ned (it is arbitrary as long as you
don’t select a known format. The common dialog box here is named
cdlFiles.
42
cdlFiles.Filter = "Files (*.ned)|*.ned"
cdlFiles.DefaultExt = "ned"
cdlFiles.DialogTitle = "Save File"
cdlFiles.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist
On Error GoTo No_Save
cdlFiles.ShowSave
Open cdlFiles.FileName For Output As #1
Print #1, Val(txtEdit.Text)
Close 1
Exit Sub
No_Save:
Resume ExitLine
ExitLine:
Exit Sub

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
visual basic v6 introduction
visual basic v6 introductionvisual basic v6 introduction
visual basic v6 introduction
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
Visual Basic Programming
Visual Basic ProgrammingVisual Basic Programming
Visual Basic Programming
 
Visual basic
Visual basicVisual basic
Visual basic
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
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
 
Meaning Of VB
Meaning Of VBMeaning Of VB
Meaning Of VB
 
Part 12 built in function vb.net
Part 12 built in function vb.netPart 12 built in function vb.net
Part 12 built in function vb.net
 
Vb tutorial
Vb tutorialVb tutorial
Vb tutorial
 
Visusual basic
Visusual basicVisusual basic
Visusual basic
 
Chapter03 Ppt
Chapter03 PptChapter03 Ppt
Chapter03 Ppt
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE Introduction
 
Vb6.0 Introduction
Vb6.0 IntroductionVb6.0 Introduction
Vb6.0 Introduction
 
Visual programming
Visual programmingVisual programming
Visual programming
 
Buttons In .net Visual Basic
Buttons In .net Visual BasicButtons In .net Visual Basic
Buttons In .net Visual Basic
 
Visual basic
Visual basicVisual basic
Visual basic
 

Ähnlich wie Vb6.0 intro

COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxCOM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxAnasYunusa
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshopdhi her
 
Chapter 1
Chapter 1Chapter 1
Chapter 1gebrsh
 
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
 
Refinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami OlusegunRefinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami OlusegunEngr. Adefami Segun, MNSE
 
Book management system
Book management systemBook management system
Book management systemSHARDA SHARAN
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lecturesmarwaeng
 
VB6_INTRODUCTION.ppt
VB6_INTRODUCTION.pptVB6_INTRODUCTION.ppt
VB6_INTRODUCTION.pptBhuvanaR13
 
Vb ch 3-object-oriented_fundamentals_in_vb.net
Vb ch 3-object-oriented_fundamentals_in_vb.netVb ch 3-object-oriented_fundamentals_in_vb.net
Vb ch 3-object-oriented_fundamentals_in_vb.netbantamlak dejene
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1guest38bf
 
Getting started with test complete 7
Getting started with test complete 7Getting started with test complete 7
Getting started with test complete 7Hoamuoigio Hoa
 
object oriented fundamentals in vb.net
object oriented fundamentals in vb.netobject oriented fundamentals in vb.net
object oriented fundamentals in vb.netbantamlak dejene
 

Ähnlich wie Vb6.0 intro (20)

Ms vb
Ms vbMs vb
Ms vb
 
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptxCOM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptx
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)
 
Refinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami OlusegunRefinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami Olusegun
 
Book management system
Book management systemBook management system
Book management system
 
Software engineering modeling lab lectures
Software engineering modeling lab lecturesSoftware engineering modeling lab lectures
Software engineering modeling lab lectures
 
VB6_INTRODUCTION.ppt
VB6_INTRODUCTION.pptVB6_INTRODUCTION.ppt
VB6_INTRODUCTION.ppt
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
ArduinoWorkshop2.pdf
ArduinoWorkshop2.pdfArduinoWorkshop2.pdf
ArduinoWorkshop2.pdf
 
Vb ch 3-object-oriented_fundamentals_in_vb.net
Vb ch 3-object-oriented_fundamentals_in_vb.netVb ch 3-object-oriented_fundamentals_in_vb.net
Vb ch 3-object-oriented_fundamentals_in_vb.net
 
Vb 6ch123
Vb 6ch123Vb 6ch123
Vb 6ch123
 
Visual basic
Visual basic Visual basic
Visual basic
 
Vb%20 tutorial
Vb%20 tutorialVb%20 tutorial
Vb%20 tutorial
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1
 
Getting started with test complete 7
Getting started with test complete 7Getting started with test complete 7
Getting started with test complete 7
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
 
object oriented fundamentals in vb.net
object oriented fundamentals in vb.netobject oriented fundamentals in vb.net
object oriented fundamentals in vb.net
 

Kürzlich hochgeladen

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Kürzlich hochgeladen (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

Vb6.0 intro

  • 2. Objectives  Understand the benefits of using Microsoft Visual Basic 6.0 for Windows as an application tool.  Understand the Visual Basic event-driven programming concepts, terminology, and available tools.  Learn the fundamentals of designing, implementing, and distributing a Visual Basic application.  Learn to use the Visual Basic toolbox.  Learn to modify object properties.  Learn object methods.  Use the menu design window.  Understand proper debugging and error-handling procedures.  Gain a basic understanding of database access and management using data bound controls.  Obtain an introduction to ActiveX controls and the Windows Application Programming Interface (API). 2
  • 3. What is Visual Basic?  Visual Basic Is a tool that allows you to develop Windows (Graphic User Interface - GUI) applications. The applications have a familiar appearance to the user. 3
  • 4. What is Visual Basic?  Visual Basic is event-driven, meaning code remains idle until called upon to respond to some event (button pressing, menu selection, ...). Visual Basic is governed by an event processor. Nothing happens until an event is detected. Once an event is detected, the code corresponding to that event (event procedure) is executed. Program control is then returned to the event processor. 4
  • 5. Some Features of Visual Basic  Full set of objects - you 'draw' the application  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 5
  • 6. Structure of a Visual Basic Application 6 Get back to Contents
  • 10. Contents of thE application (the Project)  Forms - Windows that you create for user interface  Controls - Graphical features drawn on forms to allow user interaction (text boxes, labels, scroll bars, command buttons, etc.) Forms and Controls are objects.)  Properties - Every characteristic of a form or control is specified by a property. Example properties include names, captions, size, color, position, and contents. Visual Basic applies default properties. You can change properties at design time or run time.  Methods - Built-in procedure that can be invoked to impart some action to a particular object.  Event Procedures - Code related to some object. This is the code that is executed when a certain event occurs.  General Procedures - Code not related to objects. This code must be invoked by the application.  Modules - Collection of general procedures, variable declarations, and constant definitions used by application. 10
  • 12. Main Window  The Main Window consists of the title bar, menu bar, and toolbar. 12
  • 14. 14
  • 15. Contents of the Main Window 15 The menu bar has drop-down menus from which you control the operation of the Visual Basic environment. The toolbar has buttons that provide shortcuts to some of the menu options.
  • 18. 18 The Properties Window is used to establish initial property values for objects. The drop-down box at the top of the window lists all objects in the current form. Two views are available: Alphabetic and Categorized. Under this box are the available properties for the currently selected object.
  • 19. The Form Layout Window shows where (upon program execution) your form will be displayed relative to your monitor’s screen: 19 The Project Window displays a list of all forms and modules making up your application. You can also obtain a view of the Form or Code windows (window containing the actual Basic coding) from the Project window.
  • 20. Example: Stopwatch application The application is used to calculate the time elapsed between two events. The user starts a timer, once the second event tops, the user stops the timer, the time duration is displayed. The steps are: 1. Drawing controls 2. Setting properties of the controls 3. Writing code 20
  • 21. 1. Drawing Controls 1. Start new project 2. Draw 3 command buttons on the form 3. Draw 6 labels on the form 21
  • 22. 2. Setting properties of the controls The properties of the controls can be modified in two different ways:  Setting properties during design time. In this way you click on the object (form or control) in the form window, then click on the Properties Window or the Properties Window button in the tool bar.  Setting properties during run time. In this way you can set or modify properties while your application is running. To do this, you must write some code. The code format is: ObjectName.Property = NewValue Such a format is referred to as dot notation. For example, to change the BackColor property of a form name frmStart, you may type: frmStart.BackColor = BLUE 22
  • 23. Setting properties during design time  Here we selected the form window and clicked on the properties window. Notice that the from name here (which is the most important property) is frmStopWatch.  Object names can be up to 40 characters long, must start with a letter, must contain only letters, numbers, and the underscore (_) character. 23
  • 24. Setting Properties in stopwatch example The following table shows the properties you are going to change for the objects you put on the form. 24 Name Caption Border Style Form1 frmStopWatch Stopwatch Application 1-Fixed Single Command1 cmdStart &Start Timing Command2 cmdEnd &End Timing Command3 cmdExit E&xit Label1 Start Time Label2 End Time Label3 Elapsed Time Label4 lblStart 1-Fixed Single Label5 lblEnd 1-Fixed Single Label6 lblElapsed 1-Fixed Single Property Object
  • 25. Writing Code  Variable Declaration  Variables are used by Visual Basic to hold information needed by the application. ○ Rules used in naming (declaring) variables: I. No more than 40 characters II. They may include letters, numbers, and underscore (_) III. The first character must be a letter IV. You cannot use a reserved word (word needed by Visual Basic) 25
  • 26. Visual Basic Data Types 26 Data Suffix Boolean None Integer % Long (Integer) & Single (Floating) ! Double (Floating) # Currency @ Date None Object None String Variant None
  • 27. Private Sub Command1_Click() a% = Text1.Text Text2.Text = a ^ 2 End Sub 27 Private Sub Command1_Click() Static a As Integer a = Text1.Text Text2.Text = a ^ 2 End Sub Implicit declaration of the variable a. There are three ways for a variable to be typed (declared): 1. Default 2. Implicit 3. Explicit If variables are not implicitly or explicitly typed, 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.
  • 28. Option Explicit Dim a As Integer Private Sub Command1_Click() a = Text1.Text Text2.Text = a ^ 2 End Sub Private Sub Command3_Click() a = Text1.Text Text3.Text = 2 * a + 5 End Sub 28 Explicit declaration of the variable a.
  • 30. Global Declaration of a variable  For the variable to be declared globally, it should be declared in a module, to create a module, 30
  • 31. How to Create a Module 31 In the module declare the variables by writing the following line: Global a, b, c As Long Dim c As Integer In this way the variables will be kept in the whole code as they been defined.
  • 32. The Visual Basic Language  Visual Basic Statements and Expressions The simplest statement is the assignment statement. It consists of a variable name, followed by the assignment operator (=), followed by some sort of expression. • StartTime = Now • Explorer.Caption = "Captain Spaulding" • BitCount = ByteCount * 8 • Energy = Mass * LIGHTSPEED ^ 2 • NetWorth = Assets – Liabilities Statements normally take up a single line with no terminator. Statements can be stacked by using a colon (:) to separate them. Example: • StartTime = Now : EndTime = StartTime + 10 32
  • 33.  Visual Basic Operators arithmetic operators:  The simplest operators carry out arithmetic operations. These operators in their order of precedence are: Operator Operation 1. ^ Exponentiation 2. * / Multiplication and division 3. Integer division (truncates) 4. Mod Modulus 5. + - Addition and subtraction Parentheses around expressions can change precedence. comparison operators: Operator Comparison 1. > Greater than 2. < Less than 3. >= Greater than or equal to 4. <= Less than or equal to 5. = Equal to 6. <> Not equal to The result of a comparison operation is a Boolean value (True or False). 33
  • 34. logical operators Operator Operation 1. Not Logical not 2. And Logical and 3. Or Logical or  The Not operator simply negates an operand.  The And operator returns a True if both operands are True else, it returns a False.  · The Or operator returns a True if either one of its operands is True, else it returns a False. Logical operators follow arithmetic operators in precedence. 34
  • 35. Visual Basic Functions Some of the built in visual basic functions are given here for example 35 Function Value returned Abs Absolute value Asc ASCII or ANSI code of a character Chr Character corresponding to a given ASCII or ANSI code Cos Cosine of an angle Date Current date as a text string Format Date or number converted to a text string Left Selected left side of a text string Len Number of characters in a text string Mid Selected portion of a text string Now Current time and date Right Selected right end of a text string Rnd Random number Sin Sine of an angle Sqr Square root of a number Str Number converted to a text string Time Current time as a text string Timer Number of seconds elapsed since midnight Val Numeric value of a given text string
  • 36. Visual Basic Symbolic Constants Functions and objects always require data arguments that affect their operation and return values you want to read and interpret. These arguments and values are constant numerical data and difficult to interpret based on just the numerical value. To make these constants more understandable, Visual Basic assigns names to the most widely used values, these are called symbolic constants. You can find such constants here. 36
  • 37. MsgBox Arguments Constants 37 Constant Value Description vbOKOnly 0 OK button only (default) vbOKCancel 1 OK and Cancel buttons. vbAbortRetryIgnore 2 Abort, Retry, and Ignore buttons. vbYesNoCancel 3 Yes, No, and Cancel buttons. vbYesNo 4 Yes and No buttons. vbRetryCancel 5 Retry and Cancel buttons. vbCritical 16 Critical message. vbQuestion 32 Warning query. vbExclamation 48 Warning message. vbInformation 64 Information message. vbDefaultButton1 0 First button is default (default) vbDefaultButton2 256 Second button is default. vbDefaultButton3 512 Third button is default. vbApplicationModal 0 Application modal message box vbSystemModal 4096 System modal message box.
  • 38. Example: Temperature conversion The Fahrenheit temperature is converted into Celsius by the following formula The interface should look like shown here 38 9 5 *)32F(C 
  • 39. Creating File for Editing A file is being creating for input, output and as file editor. 1. Create new project 2. On the form draw a textbox as large as the size of the form 3. Add from the tool box a COMMON DIALOG BOX. If it is not there, follow the steps below a. From PROJECT menu select components b. Scroll the components to MICROSOFT DIALOG BOX and check the box . c. It is now on the toolbox bar. 4. Notice its name which you will use in the code. 5. Now, use from TOOLS the menu editor to add (file) and (format) menus. 39
  • 40. File Menu 40 Use the MNUE EDITOR to write the file menu components. The code: •Exit code Click on exit in the created file menu, and start writing the code for ending the run. 'Make sure user really wants to exit Dim Response As Integer Response = MsgBox("Are you sure you want to exit the note editor?", vbYesNo + vbCritical + vbDefaultButton2, "Exit Editor") If Response = vbNo Then Exit Sub Else End End If
  • 41. • New code Click on New in the created file menu, and start writing the code for creating new file. 41 'If user wants new file, clear out text Dim Response As Integer Response = MsgBox("Are you sure you want to start a new file?", vbYesNo + vbQuestion, "New File") If Response = vbYes Then txtEdit.Text = "" Else End If
  • 42. • Save code Click on Save in the created file menu, and start writing the code for saving the created file with extension ned (it is arbitrary as long as you don’t select a known format. The common dialog box here is named cdlFiles. 42 cdlFiles.Filter = "Files (*.ned)|*.ned" cdlFiles.DefaultExt = "ned" cdlFiles.DialogTitle = "Save File" cdlFiles.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist On Error GoTo No_Save cdlFiles.ShowSave Open cdlFiles.FileName For Output As #1 Print #1, Val(txtEdit.Text) Close 1 Exit Sub No_Save: Resume ExitLine ExitLine: Exit Sub