How to transfer parameters to a VB application?

I want to call a VB6 EXE using parameters,
for example:
     StartDownload.exe  parameter1,parameter2
and the program of startdownload.exe can get the
value of parameters and use it in the program.

Can I do that? and How?

hxbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tg_georgeCommented:
Goto project properties (right click on the project name on the side box) .Select make tab and at the bottom you have command line arguments. add the argumets there and compile.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tg_georgeCommented:
To run Visual Basic project test.vbp,
vb5.exe /r test.vbp
0
hxbAuthor Commented:
Please give me more detail information.

I want to call the StartDownload.exe
and in the Startdownload.exe,  it have some
code such as:
    msgbox parameter1

how can I use the parameter1 in the startdownload.exe
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

caraf_gCommented:
In your VB program you'll be able to check your Command$, which contains all your command line parameters.

For example if you run
YourExecutable.exe blah blah /x:Homer -y:doh! z(woohoo!) then within your exe if you do:

Dim strCommandText As String
strCommandText = Command

if you look at strCommandText, it will contain
"blah blah /x:Homer -y:doh! z(woohoo!)"
It is up to you to interpret the string.


Also, straight from the VB help text:
Command Function Example
This example uses the Command function to get the command line arguments in a function that returns them in a Variant containing an array.

Function GetCommandLine(Optional MaxArgs)
   'Declare variables.
   Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
   'See if MaxArgs was provided.
   If IsMissing(MaxArgs) Then MaxArgs = 10
   'Make array of the correct size.
   ReDim ArgArray(MaxArgs)
   NumArgs = 0: InArg = False
   'Get command line arguments.
   CmdLine = Command()
   CmdLnLen = Len(CmdLine)
   'Go thru command line one character
   'at a time.
   For I = 1 To CmdLnLen
      C = Mid(CmdLine, I, 1)
      'Test for space or tab.
      If (C <> " " And C <> vbTab) Then
         'Neither space nor tab.
         'Test if already in argument.
         If Not InArg Then
         'New argument begins.
         'Test for too many arguments.
            If NumArgs = MaxArgs Then Exit For
            NumArgs = NumArgs + 1
            InArg = True
         End If
         'Concatenate character to current argument.
         ArgArray(NumArgs) = ArgArray(NumArgs) & C
      Else
         'Found a space or tab.
         'Set InArg flag to False.
         InArg = False
      End If
   Next I
   'Resize array just enough to hold arguments.
   ReDim Preserve ArgArray(NumArgs)
   'Return Array in Function name.
   GetCommandLine = ArgArray()
End Function


0
tg_georgeCommented:
C:\vb5.exe /r Startdownload.exe
or
 Start-> Run->Browse
Startdownload.exe i am george


In the project code
parameter1 = command
msgbox parameter1

paramter1 displays
i am george.
to get the 1 st parameter use the substr
or other string functions.

0
tg_georgeCommented:
C:\vb5.exe /r Startdownload.exe
or
 Start-> Run->Browse
Startdownload.exe i am george


In the project code
parameter1 = command
msgbox parameter1

paramter1 displays
i am george.
to get the 1 st parameter use the substr
or other string functions.

0
tg_georgeCommented:
to get the first parameter para1,second para2 ,3 rd para3 use

dim parmeter as string
 'contain all the parameters
parameter = command
dim next_pos as integer
dim cur_pos as integer

next_pos = instr(1,parameter,' ') -1
'stores the position of space
'after the first paramter
para1 = mid(parameter,1,next_pos)
msgbox para1

cus_pos = next_pos +1
next_pos = instr(cur_pos,paramter,' ')-1
'stores the 2 nd space
para2 = mid(paramter,cur_pos,next_pos)
msgbox para2

repaeat this for the any number of paramters
0
hxbAuthor Commented:
Thank
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.