fpoyavo
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
Try this
'This is .net code
Dim args As [String]() = Environment.GetCommandLine Args()
Console.WriteLine("GetComm andLineArg s: {0}", [String].Join(", ", arguments))
Thanks,
~ fantasy ~
'This is .net code
Dim args As [String]() = Environment.GetCommandLine
Console.WriteLine("GetComm
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
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