ARTICLE

How to Pass Parameter in EXE

Posted by Pragati Articles | General April 05, 2006
Sometimes a developer has to call an EXE from another EXE.While calling EXE there can be a requirement to pass parameter. This article shows how to do that.
 
Reader Level:

Sometimes a developer has to call an EXE from another EXE. While calling EXE there can be a requirement to pass parameter.

Use the following code in the global module to build an EXE which is calling other EXE. Set startup Object to Submain() function.

In the example two parameters are passed from the EXE and calling EXE is capturing them here. Parameters are paased as string seprated by Space " ".

Imports System.Windows.Forms 

Module Module1

 

        Public Sub main()

            Dim frm As New Form1

            Dim str() As String

            str = GetCommandLineArgs()

            If (UBound(str) >= 0) Then

                a = str(0).ToString

                b = str(1).ToString

            End If

            Application.Run(frm)

        End Sub

 

        Function GetCommandLineArgs() As String()

            ' Declare variables.

            Dim separators As String = " "

            Dim commands As String = Microsoft.VisualBasic.Command()

            Dim args() As String = commands.Split(separators.ToCharArray)

            Return args

        End Function

 

End Module

Write the following code from where EXE has to be called. Here Two parameters 1 and M are going to be passed.

proc.Start(Application.StartupPath & "\Sambandh.exe", "1 M")

share this article :
post comment
 

how can we pass parameters to main of C Program executable, from VB.NET interface?

Posted by Subash Koirala Jun 17, 2009

how can we pass parameters to main of C Program executable, from VB.NET interface.

Posted by Subash Koirala Jun 17, 2009

Private Sub TXTPACK_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TXTPACK.KeyPress

AllowDecimals(TXTPACK, Asc(e.KeyChar))

End Sub

 

Public Function AllowDecimals(ByVal txt As TextBox, ByVal KeyAscii As Integer) As Boolean

AllowDecimals = True

If KeyAscii = Keys.Enter Or KeyAscii = Keys.Tab _

Or KeyAscii = 8 Then Exit Function

If Not (KeyAscii > 47 And KeyAscii < 59) And Not (KeyAscii = 46 And Not (InStr(1, txt.Text, ".") > 0)) Then

If Not KeyAscii = 8 Then

KeyAscii = 0

AllowDecimals = False

End If

End If

End Function

Posted by lalit agrawal Nov 01, 2008

Private Sub TXTPACK_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TXTPACK.KeyPress AllowDecimals() End Sub Public Function AllowDecimals(ByVal txt As TextBox, ByVal KeyAscii As Integer) As Boolean AllowDecimals = True If KeyAscii = Keys.Enter Or KeyAscii = Keys.Tab _ Or KeyAscii = 8 Then Exit Function If Not (KeyAscii > 47 And KeyAscii < 59) And Not (KeyAscii = 46 And Not (InStr(1, txt.Text, ".") > 0)) Then If Not KeyAscii = 8 Then KeyAscii = 0 AllowDecimals = False End If End If End Function

Posted by lalit agrawal Nov 01, 2008
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Diagram
Become a Sponsor