Solved

Passing arguments to an application

Posted on 2003-11-30
5
286 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
[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
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 7 hours left to enroll

621 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