Solved

Command Arguments

Posted on 2000-02-22
6
254 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
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.

 

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

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
VBA color chart bars 12 78
How to debug this code 7 56
Windows Script Host failed (Access is denied.) error 6 109
vb6 connector to SQL Server 2 34
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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

895 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

15 Experts available now in Live!

Get 1:1 Help Now