Reputation: 1236
I have done this a few times in c#, but for vb.net do I use My.Application.CommandLineArgs as follows or is there a better way?
Dim argListArray As New ArrayList
For Each argument As String In My.Application.CommandLineArgs
argListArray.Add(argument)
Next
If argListArray.Count = 5 Then
ImageName = argListArray(0).ToString
ImageAddress = argListArray(1).ToString
ImagePort = argListArray(2).ToString
FileLoc = argListArray(3).ToString
JPEGQuality = argListArray(4).ToString
Else
'TODO invalid # args
End If
Upvotes: 2
Views: 4571
Reputation: 39152
Agreed...just use My.Application.CommandLineArgs
directly:
If My.Application.CommandLineArgs.Count = 5 Then
ImageName = My.Application.CommandLineArgs(0)
ImageAddress = My.Application.CommandLineArgs(1)
ImagePort = My.Application.CommandLineArgs(2)
FileLoc = My.Application.CommandLineArgs(3)
JPEGQuality = My.Application.CommandLineArgs(4)
Else
' TODO invalid # args
End If
Upvotes: 3