Hanika,
I don't know of any pre-built functionality, however it should not be that
hard to create something:
For example you could use a regular expression to parse each parameter.
Something like:
Imports System.Text.RegularExpressions
Const pattern As String = "^/(?<name>\w+)(?:\:(?<value>.+)$|$)"
Dim argRegEx As New Regex(pattern, RegexOptions.Compiled)
For Each arg As String In Environment.GetCommandLineArgs()
Debug.WriteLine(Nothing, arg)
Debug.Indent()
With argRegEx.Match(arg)
If .Success Then
Debug.WriteLine(.Groups("name"), "name")
Debug.WriteLine(.Groups("value"), "value")
End If
End With
Debug.Unindent()
Next
I would consider encapsulating the above in a class where I populate a
HashTable with the name/value pairs.
Of course you could use standard String functions to parse each parameter
also:
For Each arg As String In Environment.GetCommandLineArgs()
Debug.WriteLine(Nothing, arg)
Debug.Indent()
If arg.StartsWith("/") Then
Dim index As Integer = arg.IndexOf(":"c)
Dim name As String
Dim value As String
If index <> -1 Then
name = arg.Substring(1, index - 1)
value = arg.Substring(index + 1)
Else
name = arg.Substring(1)
value = String.Empty
End If
Debug.WriteLine(name, "name")
Debug.WriteLine(value, "value")
End If
Debug.Unindent()
Next
Hope this helps
Jay
"Hanika" <Ha****@discussions.microsoft.com> wrote in message
news:39**********************************@microsof t.com...
Hello All,
I onced used a very efficient method in VBScript to retrive nammed
arguments
passed on the commanline using:
WScript.Arguments.Named.Item ("ArgumenName").
That is, the call to the script would be somthing like:
script.wsf /ArgName:"Value of argument"
Does anyone know if there is an equivalent in VB.NET?
BTW: I am currently using System.Environment.GetCommandLineArgs and I
have
also used the Main (args()) constructor...
Any comments are greatly appreciated!
Hanika