Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Arguments to a VB executable 1

Status
Not open for further replies.

ndalli

Programmer
Nov 6, 1999
76
MT
Hi,<br>
<br>
I am trying to create an EXE in VB to which one is able to pass a number of arguments. I tried to enter the variable list into the sub main procedure but VB doesn't except it. Does anybody has a solution of this?.<br>
<br>
Thanks in advance
 
use the &quot;Command&quot; word<br>
<br>
in the Load event of your VB app<br>
check what it is<br>
here is a sub I use for that purpose.<br>
--------------------<br>
'put his in your Form_load<br>
Get_Comd_Lin<br>
<br>
Public Sub Get_Comd_Lin()<br>
Comd = Command<br>
If Comd = &quot;&quot; Then ' If no command line.<br>
Msg = &quot;There is currently no command-line string.&quot; & Chr$(10)<br>
Msg = Msg & &quot;Must type in /E 140 /S 2 at least to make Run&quot; & Chr$(10)<br>
Msg = Msg & &quot;E=Your Extension S=Your Serial Port&quot;<br>
Style = 0 'display OK button<br>
Title = &quot;NO Command Line option&quot; ' Define title.<br>
Response = MsgBox(Msg, Style, Title)<br>
NoComdLine = True<br>
MousePointer = 0<br>
Exit Sub<br>
Else ' Put command line into message.<br>
Msg = &quot;'&quot; & Comd & &quot;'&quot;<br>
End If<br>
For a = 1 To Len(Comd)<br>
Got_Sl = InStr(a, Comd, &quot;/&quot;)<br>
Got_A_Switch = Mid$(Comd, a + 1, 1)<br>
Debug.Print a, Got_A_Switch<br>
If UCase$(Got_A_Switch) = &quot;S&quot; Then<br>
SerialPort = Val(Mid(Comd, a + 3, 1))<br>
a = a + 4<br>
ElseIf UCase$(Got_A_Switch) = &quot;T&quot; Then<br>
TimerVal = Mid(Comd, a + 2, 6)<br>
Debug.Print TimerVal<br>
Exit For<br>
End If<br>
<br>
Next<br>
<br>
End Sub<br>
---------------------<br>
you can pass several parameters and parse them out.<br>
I use the Pipe symbol &quot;¦&quot; to separate parameters now but in this sub I used the slash &quot;/&quot;.<br>
<br>
Hope this Helps<br>
<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top