Visual Basic Reference

Visual Studio 6.0

Drive Property

See Also    Example    Applies To

Returns or sets the selected drive at run time. Not available at design time.


object.Drive [= drive]

The Drive property syntax has these parts:

Part Description
Object An object expression that evaluates to an object in the Applies To list.
Drive A string expression that specifies the selected drive.


The valid drives for the Drive property include all drives present in or connected to the system when the control is created or refreshed at run time. The default setting of the Drive property is the current drive.

When reading this property setting, the selected drive is returned in one of the following formats:

  • Floppy disks "a:" or "b:", and so on

  • Fixed media "c: [volume id]"

  • Network connections "x: \\server\share"

When setting this property:

  • Only the first character of the string is significant (the string isn't case-sensitive).

  • Changing the setting for the Drive property invokes a Change event.

  • Selecting a drive that isn't present causes an error.

  • Setting this property also regenerates the drive list, providing a way in code to track network connections added since the control was created.

If the FileName property is set to a qualified network path without a drive designation, the value of the Drive property is a zero-length string (""), no drive is selected, and the ListIndex property setting is 1.

Note   The Drive property returns a different value from the ListIndex property, which returns the list box selection.