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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
tg_georgeConnect With a Mentor Commented:
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
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
All Courses

From novice to tech pro — start learning today.