?
Solved

Command Arguments

Posted on 2000-02-22
6
Medium Priority
?
262 Views
Last Modified: 2010-05-02
hi, i am wondering how to add command arguments to a program.  say for example, i had an application called app.exe.  i would like to be able to put in the run command "app.exe /form2" and have the application open to form 2.  if i wanted to open form 3, i would put in the run command "app.exe /form3"

i've seen this kinda stuff done before.  particularly, MS internet explorer.  

i am very picky with answers for my questions ...BUT... if someone could give me a very complete sample code on how to do this, i will give you 450 PTS!!!!!!
0
Comment
Question by:llcoolmel
[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
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 1900 total points
ID: 2549258
All you have to do is look at the Command function.... It returns all of the arguments in the command line as a string...


For example:

if instr(1,Command,"/FORM2",1) > 0 then
    MsgBox "/Form2 argument found"
End If


Cheers!
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2549266
By the way, you can pass arguments during development to test your code...

Click "Project->Project Properties..."

On the "Make" tab, There is a text box called "Command Line Arguments:".  Anything you put in that textbox will be passed to your program in Command as if it were typed in on the command line...

Cheers!
0
 
LVL 2

Expert Comment

by:alokanant
ID: 2549400
Go to project properties dialog box,

Make Sub Main as the Startup Object.
Add a form named Form1 to your project.

Add a module to your project
Define the following function in it -

Sub Main()
    If Command = "Form1" Then
        Form1.Show
    End If
End Sub

Now create an exe for your project. If the name of your exe is MyApp.EXE and it is in the root directory then the following command shall show the Form1

C:\MyApp Form1

Type the above command in the Start -> Run dialog box.

hth
Alok.
0
Independent Software Vendors: 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!

 

Author Comment

by:llcoolmel
ID: 2556553
Adjusted points to 475
0
 

Author Comment

by:llcoolmel
ID: 2556554
your code works GREAT!!!!  thanks for your answer.  as promised, here's 450 pts PLUS a little extra...
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2556653
Thanks for the points! Glad I could help!


Cheers!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 Month11 days, 3 hours left to enroll

770 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