Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to Set Command line arguments for a VB application

Posted on 2004-10-16
3
Medium Priority
?
223 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 53

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 53

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
Suggested Courses

715 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