ChDrive Statement


ChDrive drivename

Changes the default drive.

The parameter drivename is a string and must correspond to a an existing drive.  If drivename contains more than one letter, only the first character is used.

Example:

    Sub Main()

        Dim Msg, NL   ' Declare variables.

        NL = Chr(10)   ' Define newline.

        CurPath = CurDir()   ' Get current path.

        ChDir "\"

        ChDrive "C:"

        Msg = "The current directory has been changed to "

        Msg = Msg & CurDir() & NL & NL & "Press OK to change back "

        Msg = Msg & "to your previous default directory."

        MsgBox Msg   ' Get user response.

        ChDir CurPath   ' Change back to user default.

        Msg = "Directory changed back to " & CurPath & "."

        MsgBox Msg   ' Display results.

    End Sub


Related Topics:

CurDir Function

MkDir Statement

RmDir Statement