Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

My.Application Object 

Provides properties, methods, and events related to the current application.

The properties exposed by the My.Application object return data that is associated only with the current application or DLL. No system-level information can be altered with My.Application.

Some members are available only for Windows Forms or console applications.

This example uses the My.Application.CommandLineArgs property to examine the application's command-line arguments. If an argument is found that starts with /input=, the rest of that argument is displayed.

Private Sub ParseCommandLineArgs()
    Dim inputArgument As String = "/input="
    Dim inputName As String = ""

    For Each s As String In My.Application.CommandLineArgs
        If s.ToLower.StartsWith(inputArgument) Then
            inputName = s.Remove(0, inputArgument.Length)
        End If

    If inputName = "" Then
        MsgBox("No input name")
        MsgBox("Input name: " & inputName)
    End If
End Sub

Namespace: Microsoft.VisualBasic.ApplicationServices

Class: WindowsFormsApplicationBase (the base class ConsoleApplicationBase provides members available in console applications, and its base class ApplicationBase provides the members that are available in all projects)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft