473,509 Members | 3,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB .NET Commandline Argument questions

1 New Member
Dear all,
I would like to ask questions about my VB.net program. The executable file of the program is called "PSP.exe"
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.  
  3.         Dim commandline As String = Environment.CommandLine 
  4.         Dim myParam As String = ""
  5.         For Each param As String In _
  6.         My.Application.CommandLineArgs
  7.  If param = "-s" Then
  8.        If Convert.ToInt32(param) > 0 Then
  9.               regenSchool(param, 0)
  10.               Console.WriteLine("Arguments: " + Convert.ToInt32(My.Application.CommandLineArgs(1)) + Convert.ToInt32(My.Application.CommandLineArgs(2)))
  11.        end if
  12.  end if
  13. Next
What i wanna do is that, in command prompt, if i type "PSP.exe"
it will call the form and let user input some information.
If I type "PSP.exe -s 78", the two arguments following will be "-s" and an integer, it will do some other functions. But I cant make it.

1. Actually what is the use of Environment.CommandLine ?
2. And what is the difference between the Environment.CommandLine and looping through the My.Application.CommandLineArgs ?
3. And how to debug the program because when i press debug, i cant input any command line arguments.
4. Why can't I print the arguments out by Console.WriteLine("Arguments: " + Convert.ToInt32(My.Application.CommandLineArgs(1)) + Convert.ToInt32(My.Application.CommandLineArgs(2)) ) ?

Perhaps the questions look silly. Thank you very much for the help.

Regards,
Edmond
Sep 21 '07 #1
1 4796
Plater
7,872 Recognized Expert Expert
You should really step back higher in your code and find your Main() function.
It has you arguments and will allow you to do some proccessing before deciding to load a form or not.
(In vs2005 a class file called Program.cs is created to hold your main() function)

2) if you look up in msdn on those two things you will probably see that one maps back to the other, or that they map back to a common source.

3) In the properties of your project will be a section where you can stick command line arguments

4)if your application type is set to "windows application" (which it probably is) then a console window will not appear.
HOWEVER, when in debug mode, the IDE acts as a console window and you just have to change the tab to "Output"
Sep 21 '07 #2

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

Similar topics

1
1958
by: Imayakumar | last post by:
Hi, I am using VSS through CommandLine. I have a problem in Checking Out a file. Whenever I invoke the following command, "SS Checkout File2.txt -YAdmin " the file gets checked out to the current...
0
1338
by: pk | last post by:
I'm using SgmlReader (found at http://www.gotdotnet.com/Community/UserSamples/Details.aspx ?SampleGuid=b90fddce-e60d-43f8-a5c4-c3bd760564bc)and I'm trying to make it iterate over (process)...
5
1883
by: jcrouse | last post by:
I have the following code: Dim MyStartupArguments() As String MyStartupArguments = System.Environment.GetCommandLineArgs UBound(MyStartupArguments) RomName =...
2
7053
by: Christoph Borger | last post by:
Hello! I have wrote a windows service in vb.net. This service monitors the running processes with WMI and the Win32_Process class. Till last month all seems ok. But since the begin of september...
26
2791
by: Martin Jørgensen | last post by:
Hi, I'm learning C-programming. I have a program which I would like to modify so it takes arguments from the commandline. Let call the program: program.exe. Could somebody shortly explain how...
0
2707
by: axlq | last post by:
While trying to learn the ins and outs of the php CURL library, I decided to write a php script that posts a form on the Chicago Board of Options (CBOE) web site, which returns an ASCII text file. ...
3
1578
by: postindex | last post by:
Can I get whole commandline not only argument list. 1. When I command like this $ a.py filename 2. sys.argv is returns only argument list Is there a way to find out 'redirection'...
2
1645
by: Toby | last post by:
I'm trying to write a simple commandline wrapper: a script that runs another program as a child and relays unbuffered stdin and stdout to/from the child process, possibly filtering it. The...
3
3649
by: balakrishnan.dinesh | last post by:
hi frndz, As we know that, we can pass command line agrument for C using "scanf" commands, So as same as that, Is there any way to pass those commandline arguments through php code to C and...
0
7234
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
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7344
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
7412
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...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5652
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,...
1
5060
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...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.