CurDir Function

傳回一個變體型字串,該字串表示指定磁碟機的目前路徑。

警告圖示

This statement currently does not work as documented. See this issue for more information.


語法

CurDir [(Text As String)]

傳回值類型

字串型

參數:

Text:用於指定現有磁碟機的任意字串型表示式 (例如,「C」表示第一個硬碟機的第一個分割區)。

如果未指定磁碟機或指定的磁碟機是一個零長度字串 (""),CurDir 將傳回目前磁碟機的路徑。如果描述磁碟機的語法不正確、磁碟機不存在或者磁碟機號出現在 CONFIG.SYS 中 Lastdrive 陳述式定義的磁碟機號之後,LibreOffice Basic 將報告錯誤。

此函式不區分大小寫。

錯誤代碼:

5 無效的程序呼叫

68 裝置不可用

7 記憶體不足

51 內部錯誤

示例:

Sub ExampleCurDir

Dim sDir1 As String , sDir2 As String

    sDir1 = "c:\Test"

    sDir2 = "d:\Private"

    ChDir( sDir1 )

    MsgBox CurDir

    ChDir( sDir2 )

    MsgBox CurDir

End Sub