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

Controls 1

The document discusses controls in Visual Basic for managing drives, directories, and files. It describes: 1) A Timer control that generates an event after a specified interval time and can be used to trigger an event procedure periodically. 2) DriveListBox, DirListBox and FileListBox controls that display drives, folders, and files respectively. They have properties like Drive, Path and Filename to get/set the current selection. 3) Event handlers for the Change events of these controls to update the Path property and selection of the associated controls as the user navigates drives and folders.

Uploaded by

Sangeeta Joshi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Controls 1

The document discusses controls in Visual Basic for managing drives, directories, and files. It describes: 1) A Timer control that generates an event after a specified interval time and can be used to trigger an event procedure periodically. 2) DriveListBox, DirListBox and FileListBox controls that display drives, folders, and files respectively. They have properties like Drive, Path and Filename to get/set the current selection. 3) Event handlers for the Change events of these controls to update the Path property and selection of the associated controls as the user navigates drives and folders.

Uploaded by

Sangeeta Joshi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

http://msdn.microsoft.com/enus/library/zffx82xt(v=vs.80).

aspx

The Interval property contains a value that must range from 1 to 65,535. The value is in milliseconds (or thousandths of a second), so an Interval value of 500 would equate to half a second. The Timer control generates only one event: the Timer event. The Timer control triggers aTimer event after each interval of time goes by. Therefore, if you named a Timer control tmrClock, and if you set the control'sInterval property to 1000, Visual Basic would execute the tmrClock_Timer() event procedure approximately every second. A millisecond is one-thousandth of a second.

DriveListBox : Displays the names of the drives within and connected to the PC. The basic property of this control is the drive property, which set the drive to be initially selected in the control or returns the user's selection. DirListBox : Displays the folders of current Drive. The basic property of this control is the Path property, which is the name of the folder whose sub folders are displayed in the control. FileListBox : Displays the files of the current folder. The basic property of this control is also called Path, and it's the path name of the folder whose files are displayed.

Private Sub Drive1_Change() ' The Drive property also returns the volume label, so trim it. Dir1.Path = Left$(Drive1.Drive, 1) & ":\" End Sub When the user double-clicks on a directory name, the DirListBox control raises a Change event; you trap this event to set the FileListBox's Path property accordingly: Private Sub Dir1_Change() File1.Path = Dir1.Path End Sub Finally, when the user clicks on a file in the FileListBox control, a Click event is fired (as if it were a regular ListBox control), and you can query its Filename property to learn which file has been selected. Note how you build the complete path: Filename = File1.Path If Right$(Filename, 1) <> "\" Then Filename = Filename & "\" Filename = Filename & File1.Filename

You might also like