CurDir, CurDir$ Function
See Also Example
Returns the current path for the specified drive.
CurDir returns a Variant; CurDir$ returns a String.
The argument drive is a string expression that specifies a drive in the range A to lastdrive, where lastdrive is the maximum drive letter you set in your CONFIG.SYS file.
If no drive is specified or if drive is zero-length, CurDir[$] returns the path for the current drive. This is similar to using the CHDIR command at the system prompt without specifying a path.
An error occurs if the first character in drive lies outside the range A to lastdrive. An error also occurs if the first character in drive is not a letter, or if it corresponds to a drive that doesn't exist.
CurDir, CurDir$ Functions Example
The example uses CurDir to return the name of the current directory. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim Msg, NL ' Declare variables.
NL = Chr(10) ' Define newline.
Msg = "The current directory is: "
Msg = Msg & NL & CurDir ' Get current directory.
MsgBox Msg ' Display message.