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
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim commandline As String = Environment.CommandLine
- Dim myParam As String = ""
- For Each param As String In _
- My.Application.CommandLineArgs
- If param = "-s" Then
- If Convert.ToInt32(param) > 0 Then
- regenSchool(param, 0)
- Console.WriteLine("Arguments: " + Convert.ToInt32(My.Application.CommandLineArgs(1)) + Convert.ToInt32(My.Application.CommandLineArgs(2)))
- end if
- end if
- Next
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