|
-
May 4th, 2005, 07:14 AM
#1
Console application parameters
hello,
I have to make a .NET console application.
I wrote this console application in a module but the problem is that I need to send to it 1 parameter.
After declaring in:
Public Sub Main(ByVal mtstr As String)
'Code......
end sub
it's giving me an error "No accessible 'Main' method with an appropriate signature was found in 'IETextFileAssets'."
if i remove the parameter declaration, no errors were captured.
Can you please tell me how to send a parameter to a module in a console application ?
A sample code will appreciated.
Thanks in advance
-
May 4th, 2005, 08:16 AM
#2
Re: Console application parameters
You can "Command" to retrieve the Command Line Parameters that you pass to your application.
Code:
Public Class Module1
Shared Sub main()
Debug.WriteLine(Command)
End Sub
End Class
The above code will work, if you are just passing one parameter
If you are passing more than one Command Line Parameter, then you need to split them into an array, somewhat like this..
Code:
Public Class Module1
Shared Sub main()
Dim arrCommand() As String
'I Am assuming that parameters will be separated by a White Space
'You can change that to any other character like "," or "|"
arrCommand = Command.Split(" ")
Dim sParam As String
For Each sParam In arrCommand
Debug.WriteLine(sParam)
Next
End Sub
End Class
-
May 5th, 2005, 01:35 AM
#3
Re: Console application parameters
hi,
It worked . 1000000 Thanks
-
May 10th, 2005, 05:38 AM
#4
Re: Console application parameters
vb_the_best Hi.
I try this but i get an error that says that says:
'System.Windows.Forms.Command' is not accessible in this context because it is 'Private'.
My startup object is not a form and it a Shared Sub main() sub in a public calss.
can you help me?
-
May 10th, 2005, 10:16 AM
#5
Re: Console application parameters
use
Code:
Microsoft.VisualBasic.Command
instead of
-
May 10th, 2005, 10:38 AM
#6
Re: Console application parameters
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|