Change Drive Method
The Change Drive method changes the default drive. It does not return a value. The drive that it changes to the default drive must exist, and this drive must reside in the range that the LASTDRIVE statement in the config.sys file specifies.
You can use a colon as part of the name of the drive but it is not required.
You can use the Change Directory method to change the current directory on a drive.
Format
ChDrive drive
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
drive |
A string expression that identifies the drive that this method makes the default drive. This method changes the drive according to one of the following values that you provide in the drive argument:
|
Example
The following example changes the default drive to A:
Sub Button_Click
Dim newdrive as String
newdrive = "A"
If Left(CurDir,2) <> newdrive then
ChDrive newdrive
End If
End Sub