Link to home
Start Free TrialLog in
Avatar of fpoyavo
fpoyavoFlag for United States of America

asked on

VB GetCommandLineArgs

Hi Experts,

For some reason I cannot get thing working. I have tried all
possible code samples from Microsoft site and Experts-Exchange but
all of them give me "Object Reuired" error "424" on the line where
I have


args = GetCommandLineArgs()

args defined as Dim args() As String

Can anyone tell me what's wrong. I had to check if I missed some library but
even in my Object Library viewer I cannot see these GetCommandLineArgs.

Please help.

ASKER CERTIFIED SOLUTION
Avatar of brother7
brother7
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In addition, isn't GetCommandLineArgs a VB.NET method, not a VB6 one?
Dim VarT As String
Dim VarF As String
Dim VarC As String
Dim MyArray() As String

MyArray() = Split(Command(), " ")
For Each Item In MyArray()
       If InStr(1, Item, "-t=") Then VarT = Replace(Item, "-t=", "")
       If InStr(1, Item, "-f=") Then VarF = Replace(Item, "-f=", "")
       If InStr(1, Item, "-c=") Then VarC = Replace(Item, "-c=", "")
Next
If VarT <> "" Then MsgBox VarT
If VarF <> "" Then MsgBox VarF
If VarC <> "" Then MsgBox VarC

Replacing VarT, VarF and VarC with your specific variables of course
Just put this code at the top of your form load routine
Avatar of fantasy1001
fantasy1001

Try this

'This is .net code
Dim args As [String]() = Environment.GetCommandLineArgs()
Console.WriteLine("GetCommandLineArgs: {0}", [String].Join(", ", arguments))

Thanks,
~ fantasy ~
As brother7 states above you use the Command() function to retrieve command line args.
Using brother7's code above, In Sub Main or Form_Load use following to get array of command line args:
Dim ar
ar = GetCommandLine

To check using the VB IDE you need to set the command line properties in the make tab of the project properties dialog