Visual-Basic-10
Visual-Basic-10
Image Tool
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.
1
Mathematics and computer Applications Department-Third Class Visual Basic
The following table shows the default properties of the basic tools:
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
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.
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.
Label1.Caption = List1.ListCount
End Sub
3
Mathematics and computer Applications Department-Third Class Visual Basic
File1.Path = Dir1.Path
End Sub
Dir1.Path = Drive1.Drive
End Sub
File1.Pattern = "*.*"
End Sub
File1.Pattern = "*.EXE"
End Sub
File1.Pattern = "*.TXT"
End Sub
List1.AddItem File1.FileName
End Sub