Discussion Locked

Parameter in VB6

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How can I read the parameter in Visual Basic 6.0 executable file ?

5 replies

by andrew

We need a little more info.

Are you calling a public method of an ActiveX EXE and don't know the param type?
(in this case, you can use OLEView or set a reference to the EXE and use Object Browser)

Are you passing a command line param?

Areyou coding a method?

by mohammad_m_saggaf

If you Mean a command line arrguments like:
VBApp.exe Parm1, Parm2, ...
then you have to use COMMAND function. like the following example:
This example uses the Command function to get the command line arguments in a function that returns them ina 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 thecorrect 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 toomany 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

This discussion is closed to new replies.