0% found this document useful (0 votes)
2 views

Visual-Basic-10

The document provides an overview of using DriveListBox, DirListBox, and FileListBox controls in Visual Basic 6.0 to access the computer's file system. It includes step-by-step instructions for creating a project, coding the controls, and setting properties to display drives, directories, and files. Additionally, it offers examples for designing forms to display pictures and select files based on specific criteria.

Uploaded by

Milkah Mwangi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Visual-Basic-10

The document provides an overview of using DriveListBox, DirListBox, and FileListBox controls in Visual Basic 6.0 to access the computer's file system. It includes step-by-step instructions for creating a project, coding the controls, and setting properties to display drives, directories, and files. Additionally, it offers examples for designing forms to display pictures and select files based on specific criteria.

Uploaded by

Milkah Mwangi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Mathematics and computer Applications Department-Third Class Visual Basic

Image Tool

DriveListBox,DirListBox and FileListBox in Visual Basic 6.0

Three of the controls on the Tool Box let you access the computer’s file system. They are riveListBox,
DirListBox and FileListBox controls .

The Drive ListBox is used to display a list of drives available in your computer.When you place this
control into the form and run the program,you will be able to select different drive from your
computer.

The DirListBox is Directory ListBox is used to display the list of directories or folder in a selected
drive.When you place this control into the form and run the program,you will be able to select
different directories from a selected drive in your computer.
The FileListBox is used to display the list of files in a selected directory or folder.When you place this
control into the fo form and run the program,you will be able to a list of files in a selected directory.

First Step: Create new project in Visual Basic 6. Then Input a Controls in Form1.
Drivelistbox, Dirlistbox, and Filelistbox.

Second Step: Double click on Drive control

1
Mathematics and computer Applications Department-Third Class Visual Basic

Third Step: Code window is open. Write code here.

Private Sub Drive1_Change()


Dir1.Path = Drive1.Drive
End Sub
Private Sub DirListBox_Change()
FileListBox.Path = DirListBox.Path
End Sub

Private Sub FileListBox_Click()


filename.Caption = FileListBox.filename
End Sub

The following table shows the default properties of the basic tools:

Object Default Property


Drivelistbox Drive
Drive List Box Path
Pattern
File List Box File Name
Path

Pattern Property :This Property identifies the files displayed in the list type. The default Value for
this Property is the *. * Which does offer all types of files. If we put in these Property for example
*
.bmp files will be displayed with a subsequent feature bmp.
Determine the path where the files

Path Property:Determine the path where the files

2
Mathematics and computer Applications Department-Third Class Visual Basic

File name Property: This feature gives the file name that was selected from the list.

Example 1: Design a form to display of the pictures in the computer device

Example2 Design a form to select the file according to the specific type of option buttons and then
add it to the ListBox after clicking on a command button. And view the total numbers of files added to
the list.

Private Sub command1_Click()

Label1.Caption = List1.ListCount

End Sub

Private Sub Dir1_Change()

3
Mathematics and computer Applications Department-Third Class Visual Basic

File1.Path = Dir1.Path

End Sub

Private Sub Drive1_Change()

Dir1.Path = Drive1.Drive

End Sub

Private Sub option1_Click()

File1.Pattern = "*.*"

End Sub

Private Sub option2_Click()

File1.Pattern = "*.EXE"

End Sub

Private Sub option3_Click()

File1.Pattern = "*.TXT"

End Sub

Private Sub command2_Click()

List1.AddItem File1.FileName

Label2.Caption = "Number of Files is"

End Sub

You might also like