Visual Basic Reference

Path Property

See Also Example Applies To

Returns or sets the current path. Not available at design time. For the App object, read-only at run time.

Syntax

object.Path [= pathname]

The Path property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
pathname A string expression that evaluates to the path name.

Remarks

The value of the Path property is a string indicating a path, such as C:\Ob or C:\Windows\System. For a DirListBox or FileListBox control, the default is the current path when the control is created at run time. For the App object, Path specifies the path of the project .VBP file when running the application from the development environment or the path of the .exe file when running the application as an executable file.

Use this property when building an application's file-browsing and manipulation capabilities. Setting the Path property has effects on a control similar to the MS-DOS chdir command relative paths are allowed with or without a drive specification. Specifying only a drive with a colon (:) selects the current directory on that drive.

The Path property can also be set to a qualified network path without a drive connection using the following syntax:

\\servername\sharename\path

The preceding syntax changes the Drive property to a zero-length string ("").

Changing the value of Path has these effects:

  • For a DirListBox control, generates a Change event.

  • For a FileListBox control, generates a PathChange event.

*Note* For DirListBox, the return value of Path is different from that of List(ListIndex), which returns only the selection.