Page is a not externally linkable
- Hardware and OS Related Technologies
-- Website Technology Issues
---- Working with value passed to an exe


mack - 1:31 am on Nov 28, 2009 (gmt 0)


In one of my vb.net apps I pass a value to the exe file. I use the following code to handle the paramiter received and convert it to a string within the application.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'get command peramiters
Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
For i As Integer = 0 To CommandLineArgs.Count - 1
Dim myvariable As String
myvariable = (CommandLineArgs(i))
Label1.Text = myvariable.Length 'only used for debug

If myvariable.Length = 0 Then

do something

End If

If myvariable.Length > 0 Then

do somethign else

End If

Next
End Sub

When a paramiter is sent it handles it correctly, but if no peramiter is sent it simple ignores both if statements.

The calue being sent is collected and passed to a variale (dim) so the value exists, even if it has no content. By checking the variable lenghth I was hoping to be able to confirm or eny if a value had been passed.

Is there somethign else I need to look into to determine if a peramiter has been passed to the exe. Does having no value passed bean that peramiter.lenghth = "0" would still not work?

I can confirm the value has been sent and received. I debuged this by assigning its value to a label, it showed the correct value within the app itself.

Thanks in advance.

Mack.


Thread source:: http://www.webmasterworld.com/website_technology/4033078.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com