473,405 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

VB.NET Command Line Arguments

I am writing a program that is used to merge data from two different file types; a JBX and a JBN file. In the program there a two list boxes, one to hold the JBX file and one for the JBN. I wanted to add the ability that if a user goes into a folder, selects multiple JBX and JBN files, and opens then, the program would automatically start up and put the file into there appropriate columns. I tried the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.  
  3.         Dim param As String
  4.  
  5.  
  6.         For Each param In System.Environment.GetCommandLineArgs
  7.  
  8.             MsgBox(param)
  9.  
  10.             If param.Substring(param.Length - 3, 3).ToLower = "jbx" Then
  11.                 lstJBX.Items.Add(Path.GetFileNameWithoutExtension(param))
  12.             ElseIf param.Substring(param.Length - 3, 3).ToLower = "jbn" Then
  13.                 lstJBN.Items.Add(Path.GetFileNameWithoutExtension(param))
  14.             End If
  15.  
  16.         Next
  17.  
  18.     End Sub
I added the MsgBox code so that when I ran the program I would be able to see the arguments that were being passed to the program. However, if I select 3 JBX file and 3 JBN files and try to open them, the first message box that appears is the full path of the program which obviously isn't put in one of the list boxes because it has an EXE extension. The second message box that appears is only the full path of the first file (out of the 6) that I selected. It is put into the correct listbox, but it seems that the paths of the other five files are not being passed to the program and I can't figure out why.

The effect I'm trying to achieve is similar to that of Winamp or Window Media Player, in that you select multiple files from outside the program and the program will load and place the names of the files (without the paths) into a playlist (in my case a list box).

Any comments or help will be greatly appreciated. I am running MS VS 2005 Professional Edition on Windows XP SP2.

Thanks,

Dominick
Mar 30 '07 #1
1 4008
Killer42
8,435 Expert 8TB
Seems to me, if you tell Windows to open 6 files it will do so as 6 distinct actions, thus starting (if appropriate) the same program 6 times. When your program is started the 2nd to 6th times, it would need to detect that an instance is already running, and pass the relevant information to it. I believe that's probably how MS Word, WinAmp and so on probably handle it, though I wouldn't put too much money on that.

If your program is not coming up six times, perhaps you have something set up to prevent multiple instances executing?
Apr 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari | last post by:
can i have command line arguments in VS.NET applicatio? if yes how? Can i have some code snippets of the above functionality? I know we can acjieve this in console application form command...
6
by: Jon Hewer | last post by:
hi i am writing a little script and currently implementing command line arguments following the guide by mark pilgrim from dive into python; ...
7
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the...
2
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain...
1
by: amirmira | last post by:
I would like to set command line arguments to a service at install time. I need to do this because I need to get information from different registry locations depending on my command line argument....
1
by: Rune Jacobsen | last post by:
Hi, I've been trying to figure this one out, but my experience just doesn't have what it takes... :| I am writing an application that reads an XML file and displays the contents in various...
4
by: Roland | last post by:
Hi, I am developing a C++ project and want to pass some command line arguments in VS .NET 2003. I am in debug mode, the configuration is set to Debug and I entered my argument list in Project ->...
40
by: raphfrk | last post by:
I have a program which reads in 3 filenames from the command line prog filename1 filename2 filename3 However, it doesn't work when one of the filenames has spaces in it (due to a directory...
2
by: Milan | last post by:
Hi, Please guide me how to set command line argument and how to retrive command line argument. Senario: vb.net application should be able to execute from command prompt by passing login and...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.