Solved

How to Set Command line arguments for a VB application

Posted on 2004-10-16
3
214 Views
Last Modified: 2011-09-20
Hi
      I developed a Vb aplication that can open particular files ( say with extension  xyz ) . User can open such files from Application GUI. But i would like to enable the application when such files are double clicked. Also  How can i enable command line argument property for my application. That is if my application name is  MyApp.exe , i need to use the following  command line to start application for the file Test.xyz


MyApp "c:\Sample\Test.xyz"

so that my application starts with the file Test.xyz opened in it as if i tried to open it from Application GUI.

Thanks in Advance
0
Comment
Question by:riyasjef
[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
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 12329234
Try use the Command function.

In your form_load event, try add like:

Private Sub Form_Load()
    Dim strCmd As String
    strCmd = Command
    If strCmd <> "" Then
        msgbox strCmd
        'c:\Sample\Test.xyz
        'Do your process here..
    End If
End Sub
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 12329249
and you shoud write the code above in your Startup Object (usually it's a Form Object, or write it to Sub Main() if your app start with Main() Sub)
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12329269
To create a file association with your application, you must make a registry entry.  Here is a code example of how to do this:

Creating a Visual Basic File Association
http://vbnet.mvps.org/index.html?code/reg/association.htm

Also, to process command line args, use the Command function example on this page from MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctCommand.asp
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 57
Question about INSTR  - need to extract data MS ACCESS query 6 69
Passing a Text Box name to a Sub 6 104
Help me. 3 79
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

752 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