<< Click to Display Table of Contents >> ChDir (statement) |
ChDir [Drive:]Folder
Changes to a different current drive/folder.
Drive is an optional parameter (the default value is the current drive).
Folder is the name of the folder on the given drive.
The full path may not have more than 255 characters.
See also: CurDir, ChDrive, MkDir, RmDir
Example:
Sub Main
Dim Answer, Msg, NL
NL = Chr(10) ' Chr(10)=New line
CurPath = CurDir() ' Determine current path
ChDir "\"
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 old folder
Msg = "We are now back to the folder " & CurPath & "."
MsgBox Msg
End Sub