Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing Parameters to an application (EXE)
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00853934
Message ID:
00853954
Views:
16
Hi Pierre,

In a VB .NET Windows application, Form1 is specified as the startup object by default; however, a form-level Main method is not exposed in the source code. Behind the scenes, the Visual Basic .NET compiler inserts a Main method into the IL code to satisfy .NET’s requirement that all programs must have a Main method. This model was chosen to help simplify VB .NET Windows Forms applications. If you don’t want a form to be the first object instantiated in your VB .NET application or you need to pass parameters, you can create a new module and add a Main method to it. For example:
Module MyFirstVBNetProgram
    Function Main(ByVal CmdArgs() As String) As Integer
        ' Process any parameters
        If CmdArgs.Length > 0 Then
           ' Build a string containing all parameters
           Dim Parms, Parameter As String
	     For Each Parameter In CmdArgs
  	         Parms += Parameter & " "
	     Next
	     ' Display the parameters
	     MessageBox.Show(Parms)
        End If
        Return 0
    End Function
End Module
Then right-click on the Project and go into Properties. Change the Startup Object to the name of the Module (for the sample above: MyFirstVBNetProgram).

>Hi !
>
>Used to do it in Fox, but in VB Net...
>
>How do pass parameters to an application (exe), so that on startup I can detect if the exe was launched from my main app.
>
>The main purpose is to prevent running this application without first Login into the main app.
>
>TIA
>
>Pierre
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform