Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to Set Command line arguments for a VB application

Posted on 2004-10-16
3
Medium Priority
?
226 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
  • 2
3 Comments
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 2000 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 54

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

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 …
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 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…
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…

972 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