Hi,

I am fairly new to VB.NET and i'm just wondering if anyone can help with a problem I am having. I am looking to pass some parameters to a vb.net application fwhen I call the app from another program (written in oracle forms). My question relates to how these parameters should be handled.

In my form_load I have a test to see if anything is passed in -

<code>strBalType = My.Application.CommandLineArgs(0) </code>.

My other question is how is this app then called? For example from my command line can I just call c:\test.exe 10, and the string above will have a value of ten? I have tried testing this but I always get an index out of range exception.

Also is there a way, when debugging, I can run the project with these command line parameters being passed in from the IDE? This would save me having to build the project every time.

Hopefully someone can help with this because it has been dricing me crazy!

David.

In my form_load I have a test to see if anything is passed in -

<code>strBalType = My.Application.CommandLineArgs(0) </code>.

My other question is how is this app then called? For example from my command line can I just call c:\test.exe 10, and the string above will have a value of ten? I have tried testing this but I always get an index out of range exception.

This should work. I would place it in a test to make sure you are properly passing the arg, such as:

If My.Application.CommandLineArgs.Count > 0 Then
            MessageBox.Show(My.Application.CommandLineArgs(0))
        Else
            MessageBox.Show("No args")
        End If

Also is there a way, when debugging, I can run the project with these command line parameters being passed in from the IDE? This would save me having to build the project every time.

Click on My Project in the Solution Explorer, click on the Debug tab and enter the command line arguments in the Command line arguments field.

Thanks very much for that!

David.

Hi I have found a way to send a parameter across, but the problem I'm having is that I can't send multiple across...

In the button_click:

'This kills the process so that you don't have multiple ones running

For each process as process in system.diagnostics.process.getprocessbyname("test")
Process.kill()
Next

'This starts the process and gives the started program the new parameter
Process.Start("C:\test\test.exe", "Hello World")

In the load_form:

'This reads the parameter sent from the program and displays it in the label
Label1.text = command()

This can be done on the same form or on multiple... The only thing I can't seem to get off the internet is to send multiple parameters to the same program. I also don't know how to send a parameter to a program without having to process.start it...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.