CurDir, CurDir$ Function

See Also1COH07U              Example3ATW03>Low

Returns the current path for the specified drive.

Syntax

CurDir[$] [(drive)]

Remarks

CurDir returns a Variant8PHEAW3; CurDir$ returns a String.

The argument drive is a string expression1330R89 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.


See Also

ChDir StatementPMFGU6

ChDrive Statement377HU1E

MkDir StatementPWIGU6

RmDir StatementQ1KGU6


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.

End Sub