Solved

Command Arguments

Posted on 2000-02-22
6
256 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
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 475 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 88
SLMGR Switches Are Not Working On KMS Host 3 107
VB 6 error 5 in windows 10 but not in XP 7 63
backup program with robocopy 6 42
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

791 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