ChDir Statement

 

ChDir pathname

 

Changes the default directory

 

Pathname: [drive:] [ \ ] dir[\dir]...

 

The parameter pathname is a string limited to fewer then 128 characters.  The drive parameter is optional.  The dir parameter is a directory name.  ChDir changes the default directory on the current drive, if the drive is omitted.

 

 

Related Topics:  CurDir, CurDir$, ChDrive, Dir, Dir$, MkDir, RmDir

 

Example:

 

Sub Main ()

   Dim Answer, Msg, NL  ' Declare variables.

   NL = Chr(10)  ' Define newline.

   CurPath = CurDir()   ' Get current path.

   ChDir "\"

   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."

   Answer = MsgBox(Msg) ' Get user response.

   ChDir CurPath ' Change back to user default.

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

   MsgBox Msg ' Display results.

End Sub