Solved

Passing arguments to an application

Posted on 2003-11-30
5
280 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 56
Macro: print each sheet to pdf using ExportAsFixedFormat 11 40
Spell Check in VB6 13 96
Excel Automation VBA 19 33
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

912 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now