SlideShare a Scribd company logo
4
Most read
1
Controls:
OptionButtons (RadioButtons):
Multiple choices, but user can select only
one choice
Check Box:
Multiple choices, user can select many
choices
Combo Box:
One option can be selected
List Box:
One option can be selected
Frames:
Provide a way of grouping related controls
on a form. And, in the case of option
buttons, frames affect how such buttons
operate.
To group controls in a frame, you first draw
the frame. Then, the associated controls
must be drawn in the frame. This allows you
to move the frame and controls together.
Image Boxes:
An image box allows you to place graphics
information on a form.
Image box graphics can be resized by using the Stretch property.
Image Box Properties:
Picture Establishes the graphics file to display in the image box.
Stretch If False, the image box resizes itself to fit the graphic. If True, the graphic resizes to fit
the control area.
Drive List Box:
The drive list box control allows a user to select a valid disk drive at run-time. It displays the
available drives in a drop-down combo box. No code is needed to load a drive list box; Visual
Basic does this for us. We use the box to get the current drive identification.
Drive List Box Properties:
Drive Contains the name of the currently selected drive.
Drive List Box Events:
Change Triggered whenever the user or program changes the drive selection.
Directory List Box:
The directory list box displays an ordered, hierarchical list of the user's disk directories and
subdirectories. The directory structure is displayed in a list box.
Like, the drive list box, little coding is needed to use the directory list box – Visual Basic does
most of the work for us.
2
Directory List Box Properties:
Path Contains the current directory path.
Directory List Box Events:
Change Triggered when the directory selection is changed.
File List Box
The file list box locates and lists files in the directory specified by its Path property at run-time.
You may select the types of files you want to display in the file list box.
File List Box Properties:
FileName Contains the currently selected file name.
Path Contains the current path directory.
Pattern Contains a string that determines which files will be displayed. For example, using *.jpg
only displays files with the .jpg extension.
Synchronizing the Drive, Directory, and File List Boxes:
The drive, directory, and file list boxes are almost always used together to obtain a file name. As
such, it is important that their operation be synchronized to insure the displayed information is
always consistent.
When the drive selection is changed (drive box Change event), you should update the directory
path. For example, if the drive box is named drvExample and the directory box is dirExample,
use the code:
Dir1.Path = Drive1.Drive
When the directory selection is changed (directory box Change event), you should update the
displayed file names. With a file box named filExample, this code is:
File1.Path = Dir1.Path
Once all of the selections have been made and you want the file name, you need to form a text
string that correctly and completely specifies the file identifier. This string concatenates the
drive, directory, and file name information.
Example code for concatenating the available information into a proper file name and then
loading it into an image box is:
Dim YourFile as String
YourFile = File1.Path + "" + File1.FileName
Image1.Picture = LoadPicture(YourFile)
Note we only use properties of the file list box. The drive and directory box properties are only
used to create changes in the file list box via code.
IF Syntax:
If condition then
Statements
Else
Statements
3
End If
Loops:
For…Next Syntax:
For variable=start to end
Statements
Next
By default increment is of 1. For more increment, we write step increment, e.g. step2 for
increment of 2.
While…Wend Syntax:
While condition
Statements
inc/dec
Wend
Example:
num=Text1.Text
start= Text2.Text
end=Text3.Text
inc= Text4.Text
while start<=end
print num +”*”+start+”=”+num*start
start=val(start+inc)
wend
Do…Loop:
Do While…Loop syntax:
Do While(condition)
Statements
Inc/dec
Loop
Example:
Private Sub Command1_Click()
Dim x As Integer
x = 1
Do While x <= 10
Print x
x = x + 1
Loop
End Sub
4
Do Until…Loop syntax:
Unlike the Do While...Loop and While...Wend repetition structures, the Do Until... Loop
structure tests a condition for falsity.
Statements in the body of a Do Until...Loop are executed repeatedly as long as the condition is
False.
Do Until(condition)
Statements
Inc/dec
Loop
Example:
Private Sub Command1_Click()
Dim x As Integer
x = 1
Do Until x > 10
Print x
x = x + 1
Loop
End Sub
Message Box:
The message box is used to displays a message
Input Box:
The input box is used to take input
Some Control Events:
Click Event triggered when item in list is clicked.
Text Box Events:
Change Triggered every time the Text property changes.
LostFocus Triggered when the user leaves the text box. This is a good place to examine the
contents of a text box after editing.
Some Control Methods:
Combo Box Methods:
AddItem Allows you to insert item in list.
Clear Removes all items from list box.

More Related Content

Similar to Vb lecture notes (20)

PPTX
file handling in python using exception statement
srividhyaarajagopal
 
DOCX
There are 4 part for the project and the question may be long to rea.docx
susannr
 
DOCX
There are 4 parts for the project. The question may be long to read .docx
susannr
 
DOCX
There are 4 parts for the project. The question may be long to r.docx
susannr
 
PPTX
Data File Handling in Python Programming
gurjeetjuneja
 
PDF
Introduction to r studio on aws 2020 05_06
Barry DeCicco
 
PDF
Unit5
Abha Damani
 
PPTX
CPP homework help
C++ Homework Help
 
PDF
Windows FTK Forensics.pdf
ssusere6dc9d
 
DOCX
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
mary772
 
PPTX
Princeton's Maximum Entropy Tutorial
Dashiell Cruz
 
PPTX
Chapter 3 File and Folder Management.pptx
deejayrakib5
 
PPTX
file handling.pptx avlothaan pa thambi popa
senniyappanharish
 
PPTX
FILE HANDLING IN PYTHON Presentation Computer Science
HargunKaurGrover
 
PDF
Data analystics with R module 3 cseds vtu
LalithauLali
 
PPTX
Module 5_Reading and Writing Files.pptx.
ManjuManjunath70
 
DOCX
WPF Application
Akshay Sharma
 
PPS
Power Point Lesson 10 Part1
Nasir Jumani
 
PPTX
DFH PDF-converted.pptx
AmitKaur17
 
PDF
Data file handling
Prof. Dr. K. Adisesha
 
file handling in python using exception statement
srividhyaarajagopal
 
There are 4 part for the project and the question may be long to rea.docx
susannr
 
There are 4 parts for the project. The question may be long to read .docx
susannr
 
There are 4 parts for the project. The question may be long to r.docx
susannr
 
Data File Handling in Python Programming
gurjeetjuneja
 
Introduction to r studio on aws 2020 05_06
Barry DeCicco
 
CPP homework help
C++ Homework Help
 
Windows FTK Forensics.pdf
ssusere6dc9d
 
CMPE2300 – Lab01 - Defrag-o-maticIn this lab you will crea.docx
mary772
 
Princeton's Maximum Entropy Tutorial
Dashiell Cruz
 
Chapter 3 File and Folder Management.pptx
deejayrakib5
 
file handling.pptx avlothaan pa thambi popa
senniyappanharish
 
FILE HANDLING IN PYTHON Presentation Computer Science
HargunKaurGrover
 
Data analystics with R module 3 cseds vtu
LalithauLali
 
Module 5_Reading and Writing Files.pptx.
ManjuManjunath70
 
WPF Application
Akshay Sharma
 
Power Point Lesson 10 Part1
Nasir Jumani
 
DFH PDF-converted.pptx
AmitKaur17
 
Data file handling
Prof. Dr. K. Adisesha
 

More from alldesign (20)

DOCX
Vb lecture
alldesign
 
PDF
Color model
alldesign
 
PDF
Computer graphics circle
alldesign
 
PDF
Getstart graphic
alldesign
 
PDF
Image types,raster and vector graphics
alldesign
 
PDF
Graphics c
alldesign
 
PDF
Image types,raster and vector graphics
alldesign
 
PPTX
Graphics display devices
alldesign
 
PPT
Circles graphic
alldesign
 
PPTX
Cg applications
alldesign
 
PPTX
Types of cards
alldesign
 
PPTX
External types of hardware
alldesign
 
PPTX
Devices of computer
alldesign
 
PPTX
Internal computer hardware
alldesign
 
PPTX
Computer hardware
alldesign
 
PPTX
Types of slots
alldesign
 
PPTX
Application of computer graphic
alldesign
 
PPTX
What is computer graphics
alldesign
 
PPTX
Types of rom
alldesign
 
PPTX
Types of ram
alldesign
 
Vb lecture
alldesign
 
Color model
alldesign
 
Computer graphics circle
alldesign
 
Getstart graphic
alldesign
 
Image types,raster and vector graphics
alldesign
 
Graphics c
alldesign
 
Image types,raster and vector graphics
alldesign
 
Graphics display devices
alldesign
 
Circles graphic
alldesign
 
Cg applications
alldesign
 
Types of cards
alldesign
 
External types of hardware
alldesign
 
Devices of computer
alldesign
 
Internal computer hardware
alldesign
 
Computer hardware
alldesign
 
Types of slots
alldesign
 
Application of computer graphic
alldesign
 
What is computer graphics
alldesign
 
Types of rom
alldesign
 
Types of ram
alldesign
 
Ad

Recently uploaded (20)

PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Ad

Vb lecture notes

  • 1. 1 Controls: OptionButtons (RadioButtons): Multiple choices, but user can select only one choice Check Box: Multiple choices, user can select many choices Combo Box: One option can be selected List Box: One option can be selected Frames: Provide a way of grouping related controls on a form. And, in the case of option buttons, frames affect how such buttons operate. To group controls in a frame, you first draw the frame. Then, the associated controls must be drawn in the frame. This allows you to move the frame and controls together. Image Boxes: An image box allows you to place graphics information on a form. Image box graphics can be resized by using the Stretch property. Image Box Properties: Picture Establishes the graphics file to display in the image box. Stretch If False, the image box resizes itself to fit the graphic. If True, the graphic resizes to fit the control area. Drive List Box: The drive list box control allows a user to select a valid disk drive at run-time. It displays the available drives in a drop-down combo box. No code is needed to load a drive list box; Visual Basic does this for us. We use the box to get the current drive identification. Drive List Box Properties: Drive Contains the name of the currently selected drive. Drive List Box Events: Change Triggered whenever the user or program changes the drive selection. Directory List Box: The directory list box displays an ordered, hierarchical list of the user's disk directories and subdirectories. The directory structure is displayed in a list box. Like, the drive list box, little coding is needed to use the directory list box – Visual Basic does most of the work for us.
  • 2. 2 Directory List Box Properties: Path Contains the current directory path. Directory List Box Events: Change Triggered when the directory selection is changed. File List Box The file list box locates and lists files in the directory specified by its Path property at run-time. You may select the types of files you want to display in the file list box. File List Box Properties: FileName Contains the currently selected file name. Path Contains the current path directory. Pattern Contains a string that determines which files will be displayed. For example, using *.jpg only displays files with the .jpg extension. Synchronizing the Drive, Directory, and File List Boxes: The drive, directory, and file list boxes are almost always used together to obtain a file name. As such, it is important that their operation be synchronized to insure the displayed information is always consistent. When the drive selection is changed (drive box Change event), you should update the directory path. For example, if the drive box is named drvExample and the directory box is dirExample, use the code: Dir1.Path = Drive1.Drive When the directory selection is changed (directory box Change event), you should update the displayed file names. With a file box named filExample, this code is: File1.Path = Dir1.Path Once all of the selections have been made and you want the file name, you need to form a text string that correctly and completely specifies the file identifier. This string concatenates the drive, directory, and file name information. Example code for concatenating the available information into a proper file name and then loading it into an image box is: Dim YourFile as String YourFile = File1.Path + "" + File1.FileName Image1.Picture = LoadPicture(YourFile) Note we only use properties of the file list box. The drive and directory box properties are only used to create changes in the file list box via code. IF Syntax: If condition then Statements Else Statements
  • 3. 3 End If Loops: For…Next Syntax: For variable=start to end Statements Next By default increment is of 1. For more increment, we write step increment, e.g. step2 for increment of 2. While…Wend Syntax: While condition Statements inc/dec Wend Example: num=Text1.Text start= Text2.Text end=Text3.Text inc= Text4.Text while start<=end print num +”*”+start+”=”+num*start start=val(start+inc) wend Do…Loop: Do While…Loop syntax: Do While(condition) Statements Inc/dec Loop Example: Private Sub Command1_Click() Dim x As Integer x = 1 Do While x <= 10 Print x x = x + 1 Loop End Sub
  • 4. 4 Do Until…Loop syntax: Unlike the Do While...Loop and While...Wend repetition structures, the Do Until... Loop structure tests a condition for falsity. Statements in the body of a Do Until...Loop are executed repeatedly as long as the condition is False. Do Until(condition) Statements Inc/dec Loop Example: Private Sub Command1_Click() Dim x As Integer x = 1 Do Until x > 10 Print x x = x + 1 Loop End Sub Message Box: The message box is used to displays a message Input Box: The input box is used to take input Some Control Events: Click Event triggered when item in list is clicked. Text Box Events: Change Triggered every time the Text property changes. LostFocus Triggered when the user leaves the text box. This is a good place to examine the contents of a text box after editing. Some Control Methods: Combo Box Methods: AddItem Allows you to insert item in list. Clear Removes all items from list box.