Click to See Complete Forum and Search --> : Console application parameters


cakiki
May 4th, 2005, 07:14 AM
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

Shuja Ali
May 4th, 2005, 08:16 AM
You can "Command" to retrieve the Command Line Parameters that you pass to your application.


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..

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

cakiki
May 5th, 2005, 01:35 AM
hi,
It worked . 1000000 Thanks

leeshadmi
May 10th, 2005, 05:38 AM
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?

Shuja Ali
May 10th, 2005, 10:16 AM
use Microsoft.VisualBasic.Command instead of Command

leeshadmi
May 10th, 2005, 10:38 AM
Thanks it works good
:wave: :wave: :wave: