Search code examples
c#parameterstextboxbasic

How to add parameters to Visual Basic Program via Textbox


I am currently working on a server manager for the game DayZ. I have almost 90 % done, I have a working history of servers joined etc. I'm working on a option where the game will launch with a click of a button, which works, but i need it to connect to the server without the person having to go through all the steps.

I know the launch parameters to do so, the issue is I have to be able to let the people put in the launch parameter and then for my code to be dynamic and pickup any legit parameter for joining servers. (example: -connect=109.95.211.243 -port=2502), so I have two text boxes for them to use, but now I need my button to execute the game with those dynamic parameters.

Sorry if this is a bit confusing

Current code,

    Dim pHelp As New ProcessStartInfo

    pHelp.FileName = "C:\Program Files (x86)\Steam\SteamApps\common\DayZ\DayZ.exe"

    pHelp.Arguments =

    pHelp.UseShellExecute = True

    pHelp.WindowStyle = ProcessWindowStyle.Normal

    Dim proc As Process = Process.Start(pHelp)

Solution

  • You just have to read the values of the text boxes or dropdowns or whatever control you have and put them in the arguments string:

    pHelp.Arguments = "-connect=" + textBoxIP.Text + " -port=" + textBoxPort.Text;
    

    Note that you might want to test the actual values whether they're valid before.