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

passing a parameter to a VB developed exe 2

Status
Not open for further replies.

BlindPete

Programmer
Jul 5, 2000
711
1
0
US
for example
z:\myPath\MyVBapplicaton.exe -SomeCommand

Anyone have an example or link they could direct to that overviews hoe to handle command line parameters in a VB compiled app?

-Pete[noevil]
 
In your the form load event of the first form that opens you can do this.


If Command = "Something" then
'do something
end if
'Command is the keyword
 
This was answered by vb5prgmr in thread222-545295

Basically make a Sub Main in a BAS module and get the command parameters.

Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
Ok thanks for replying so quickly. I'll try that, but some of my apps do not have forms. They merely manipulate data w/o a display. Can pass command lines to those type of apps as well?

-Pete[noevil]
 
Start new project set the project properties
Project >> Properties >> Make (Tab) >> Command Line Arguments = BC

[this argument u can pass as command line param for compiled exe]

Then

'-- put this code in a module
Public Sub main()
Dim strParm As String
strParm = Command
Select Case strParm
Case "A"
MsgBox "here u put the stuff for command line paramete [ A ]"
Case "BC"
MsgBox "here u put the stuff for command line paramete [ BC ]"
Case Empty
MsgBox "here u put the stuff for command line paramete [ No params ]"

End Select
End
End Sub
'-- end of code line -------
 
To add to this, you would prabaly not want to leave it up to the user to detemine or guess what case to use when typing in the argument. You can add the following before validating the command line argument.

z:\myPath\MyVBapplicaton.exe -SomeCommand

strParm = UCase(Command)

...Unless the arguments should be case sensitive (highly unlikely).


Chargrams
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top