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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Command line arguments in Visual Basic 1

Status
Not open for further replies.

cdelaney

Programmer
Mar 2, 2000
8
0
0
CA
I need to know how to open a Visual Basic application and when opened run a function depending on the command line argument specified.<br>
<br>
Like this<br>
<br>
file.exe -on<br>
<br>
Any help appreciated<br>
<br>
Curtis
 
there is a word in VB called &quot;Command&quot;<br>
Any parameters apssed to your app with be in that Variable<br>
<br>
here is a very simplistic example<br>
Public Function GetComdLin()<br>
MyCommand = Command<br>
Debug.Print MyCommand<br>
If MyCommand = &quot;-on&quot; Then<br>
' do something<br>
GetComdLin = MyCommand<br>
End If<br>
<br>
End Function<br>
<br>
I would start with that and use &quot;IF&quot; statements to test for different &quot;passed&quot; values such as -on in your case<br>
<br>
you have the syntax correct for calling it i.e. file.exe -on<br>
<br>
Just put this in your Form Load event.<br>
<br>
Private Sub Form_Load()<br>
x = GetComdLin<br>
End Sub<br>
<br>
<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top