Solved

Passing arguments to an application

Posted on 2003-11-30
5
283 Views
Last Modified: 2010-05-01
How can I pass arguments to a VB application (.exe - in main()?)
How do I refer to this arguments in the code?
0
Comment
Question by:SaadDani
  • 4
5 Comments
 
LVL 11

Accepted Solution

by:
dbrckovi earned 100 total points
ID: 9848598
In Visual Basic, the command line arguments can be accessed through 'Command' string variable.
So if you wish to access only particular argument then you have to split this string to array of arguments:

Try this:
---------------------------------------
Private Sub Command1_Click()
    Dim args() As String                         'Create an empty array which will be used to store arguments
    Print Command                                'Print the entire line of arguments
    args() = Split(Command, " ")            'Split this line into an array
    For x = 0 To UBound(args)
        Print args(x)                                'Print each argument separately
    Next x
End Sub
---------------------------------------
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9848601
BTW. You have two identical questions open.
0
 

Author Comment

by:SaadDani
ID: 9848640
What type of application it must be and do I have to declare something?
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9848659
If your application is compiled to exe (any kind) then it will work.
You don't have to declare anything.
If you wish to test this during design time, then set the command line arguments under    Project  -  Properties  -  'Make' Tab   in Visual Basic
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9848663
If your application is compiled to exe (any kind) then it will work.
You don't have to declare anything.
If you wish to test this during design time, then set the command line arguments under    Project  -  Properties  -  'Make' Tab   in Visual Basic
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

828 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