Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

parsing the command line arguments

Posted on 2004-11-01
6
Medium Priority
?
261 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:sony1464
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 12467812
Hi,

Query the Command$ variable in your VB code.

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

BFN,

fp.
0
 
LVL 8

Expert Comment

by:ampapa
ID: 12467838
I think you can get by using the command function.

sub frmmain_load()
   frmmain.text1 = command
end sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Accepted Solution

by:
hes earned 200 total points
ID: 12467903
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
 
LVL 3

Author Comment

by:sony1464
ID: 12468405

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
 
LVL 8

Assisted Solution

by:ampapa
ampapa earned 200 total points
ID: 12468619
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question