📜  Application.ExecutablePath VB.NET - VBA (1)

📅  最后修改于: 2023-12-03 14:39:18.785000             🧑  作者: Mango

Application.ExecutablePath in VB.NET and VBA

Application.ExecutablePath is a property that returns the full path of the current application's executable file. This property is available in both VB.NET and VBA programming languages.

Syntax

The syntax for using Application.ExecutablePath is as follows:

In VB.NET:

Dim executablePath As String = Application.ExecutablePath

In VBA:

Dim executablePath As String
executablePath = Application.ExecutablePath
Example

Here is a sample code snippet that demonstrates the usage of Application.ExecutablePath in VB.NET:

Imports System.IO

Module Module1
    Sub Main()
        Dim executablePath As String = Application.ExecutablePath
        Console.WriteLine("Executable Path: " & executablePath)

        Dim directoryPath As String = Path.GetDirectoryName(executablePath)
        Console.WriteLine("Directory Path: " & directoryPath)
    End Sub
End Module

The above code snippet will print the executable path and its directory path to the console.

Remarks
  • The value returned by Application.ExecutablePath includes the file name of the executable file.
  • In VBA, this property is accessed using the Application object, which refers to the current instance of the application.