ChDrive (statement)

<< Click to Display Table of Contents >>

ChDrive (statement)

ChDrive Drive

Changes the current drive.

Drive is a text string specifying the drive letter.

If Drive contains more than one character, only the first character will be used.

See also: ChDir, CurDir, MkDir, RmDir

Example:

Sub Main

 Dim Answer, Msg, NL

 NL = Chr(10)                   ' Chr(10)=New line

 CurPath = CurDir()             ' Determine current path

 ChDrive "D"

 Msg = "The folder was changed to " & CurDir() & ". "

 Msg = Msg & NL & NL & "Click on OK "

 Msg = Msg & "to return to the previous folder."

 Answer = MsgBox(Msg)

 ChDir CurPath                  ' Back to the previous folder

 Msg = "We are now back to the folder " & CurPath & "."

 MsgBox Msg

End Sub