Solved

Passing arguments to an application

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

17 Experts available now in Live!

Get 1:1 Help Now