VB Unit 4 Notes
VB Unit 4 Notes
1
Coding:
Private Sub Form_Load()
Form1.WindowState = 2
Shape1.BackColor = &H8000000A
Shape1.Shape = 2
End Sub
2
Discuss about DriveListBox, DirListBox, And FileListBox Controls In Visual Basic 6.
These Three Controls are used to work with the Computer File System.
Example:
Drive1.Drive
above command is used display Available Drivers of your computer system at run time.
Output:
2.DirListBox
The DirListBox is a special list box that displays the Computer's disk directories and
subdirectories.
3
Example:
Dir1.Path
Above directory command is used to display e Computer's directories and subdirectories.
Directory List Box Properties:
Path Contains the current directory path.
Output:
3. FileListBox
FileListBox control displays all the files in a given directory.
Example:
File1.Path
Above the command is used to display files of a Directory.
4
Output
Example Program : Display a File Using DriveListBox, DirListBox, FileListBox and OLE Controls
in VB.
5
Private Sub Form_Load()
Form1.WindowState = 2
End Sub
Form Design to Display a File Using DriveListBox, DirListBox, FileListBox and OLE Controls
6
It is used to display a graphics image from any of the following types of files:
Bitmap (.bmp)
GIF file
JPEG file
Image Box Control Syntax to Display a File:
Image1.picture = LoadPicture( “Image Path Name”)
Image1.picture = LoadPicture( “D:\pictures\car.JPG”)
LoadPicture function is used to load the image in Image Box Control.
Timer Properties:
Timer1.Enabled =TRUE / FALSE
Above command is used to enable/disable the Timer Control
Timer1.Interval =10
Above command is used to define Number of milliseconds between each
invocation of the Timer Event.
7
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Output:
8
Discuss about the Picture Box Control in Visual Basic 6.0
The Picture Box Control is used to display images on a form.
It is best suited for dynamic environments - for example, when doing animation.
It is used to display a graphics image from any of the following types of files:
Bitmap (.bmp)
GIF file
JPEG file
Example Program : Animate a image using Picture Box Control & Timer in Visual Basic 6.0.
Coding:
Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
9
If Frame1.Left > Me.Width Then
Frame1.Left = 0
End If
End Sub
Form Design
10
Example Program : Write a Program to display different Shapes Using List Box Control.
Coding:
Private Sub Form_Load()
Form1.WindowState = 2
List1.AddItem "Rectangle"
List1.AddItem "Square"
List1.AddItem "Oval"
List1.AddItem "Circle"
List1.AddItem "Rounded Rectangle"
List1.AddItem "Rounded Square"
Shape1.BackColor = &H8000000A
Shape1.Shape = 2
End Sub
11
Form Design & Output:
12