Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 2nd, 2004, 07:03 PM
Authorized User
 
Join Date: Jan 2004
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Default Arguments

I want to use the argument %1 (file directory) to open a file in my program. This argument is passed to the program when an associated file is opened. How do I access the information from the argument so that the file is opened? So far I have gotten my program to open when an associated file is opened.

Thanks in advance.
 
Old September 3rd, 2004, 05:55 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default

How is it being passed to your program - through a command line? Can you explain the process you're attempting in more detail

 
Old September 3rd, 2004, 07:01 AM
Authorized User
 
Join Date: Jan 2004
Posts: 34
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, it is being passed through a command line.
 
Old September 3rd, 2004, 08:40 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You can retrieve the program command line (which includes the executable file name) as a string, or get an array of strings, where each element is an item on the command string:

Code:
' the command line passed to this program...
MessageBox.Show(Environment.CommandLine)

' the list of all the command line arguments 
' (first element is the executable name)...
Dim arg as String
For Each arg in Environment.GetCommandLineArgs
     MessageBox.Show(arg)
Next
Answer courtesy of Francisco Balena, "Programming Microsoft Visual Basic .Net", who put it so well there was no point in paraphrasing!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Query w/ arguments darkhalf Access VBA 2 March 3rd, 2008 10:04 AM
arguments relay pierre.voisin Javascript 1 February 20th, 2008 06:04 PM
multiple arguments MunishBhatia C# 2 December 8th, 2006 07:34 AM
Named arguments Bob Bedell C# 2 March 19th, 2006 09:25 PM
Program arguments bramtram VB How-To 1 August 14th, 2003 03:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.