parsing the command line arguments

How do you read values passed as a command line argument in vb6 applications. the application would be called like shown below. I would like to get the three arguments that are passed with the exe. How do i do that vb 6. thanks in advance.

C:\parser.exe JU1991020005 940604707218.txt  940604707218.idx
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

hesConnect With a Mentor Commented:
Sub Form_load()
  Dim CommandArgs
  CommandArgs = Split(Command(), " ")
  'CommandArgs(0) will contain your first argument
  'CommandArgs(1) will contain your second argument
End Sub
[ fanpages ]IT Services ConsultantCommented:

Query the Command$ variable in your VB code.

In the above example, it will contain "JU1991020005 940604707218.txt  940604707218.idx".


I think you can get by using the command function.

sub frmmain_load()
   frmmain.text1 = command
end sub
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

sony1464Author Commented:

i tried hes's example and it worked great .... now how do i get the filename without the extension from the second argument and save it in the application diresctory as filaname.doc...i really appreciate such a quick reponse....

for the above example i want a file called 940604707218.doc to be created in the application directory.
ampapaConnect With a Mentor Commented:
Assuming your still using the above, untested.

Sub Form_load()
  Dim CommandArgs
  Dim cmdFilename as string

  CommandArgs = Split(Command(), " ")
  CommandArgs(0) will contain your first argument
  CommandArgs(1) will contain your second argument
   cmdfilename =  left(CommandArgs(1), len(CommandArgs(1))-3)

   Open app.path & "\" & cmdfilename & "doc" For output As #1
         Print #1, "File created."
   Close #1

End Sub
All Courses

From novice to tech pro — start learning today.