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
LVL 3
sony1464Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
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
  'ect
End Sub
0
 
[ fanpages ]IT Services ConsultantCommented:
Hi,

Query the Command$ variable in your VB code.

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

BFN,

fp.
0
 
ampapaCommented:
I think you can get by using the command function.

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

With monday.com’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.
0
 
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
0
All Courses

From novice to tech pro — start learning today.