Solved

How to Set Command line arguments for a VB application

Posted on 2004-10-16
3
187 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 49

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 49

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

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

911 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

19 Experts available now in Live!

Get 1:1 Help Now