Hey guys! First post here.

I'm new to VB.Net programming, so I decided to make a small app that runs another app with arguments.
I think the best way to do it was selecting one option from a dropdown menu and using this option as an argument to run the app.

The clean part I did:

Public Class LanguageSelectDialog
    Private Sub LanguageSelectDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        Me.Close()
    End Sub

    Private Sub RunButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunButton.Click
        Process.Start("Blank App.exe", "")
    End Sub
End Class

Since I'm just trying out, I've made an blank app just for testing purposes. What I need to do in order to pass the selected option as argument? I'm using VisualStudio 2010.

Other 2 things that I didn't figured out:
- how can I make a form unresizable?
- how can I make the dropdown menu not editable?

Sorry if I'm asking too much for first post, but I'm in a thirst of learning! =)

Member Avatar for Unhnd_Exception
'you could have a mnuItem and set the arg to 
        'its text property or its tag.  
        'Theres all kinds of ways.

        'This item has c:\scrap.bmp for its text, which will open 
        'that image in mspaint
        Process.Start("Mspaint.exe", mnuArgs_Arg1.Text)

        'fixed size border style
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle


        'disable menu
        mnuArgs.Enabled = False
        'or
        mnuArgs_Arg1.Enabled = False
'you could have a mnuItem and set the arg to 
        'its text property or its tag.  
        'Theres all kinds of ways.

        'This item has c:\scrap.bmp for its text, which will open 
        'that image in mspaint
        Process.Start("Mspaint.exe", mnuArgs_Arg1.Text)

        'fixed size border style
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle


        'disable menu
        mnuArgs.Enabled = False
        'or
        mnuArgs_Arg1.Enabled = False

Thanks! And sorry for the late response, I had to go to work.
I didn't get the part or the arguments... I thought on something like... user select a item from the dropdown menu and that changes the value of a variable, which will be the parameter. Something like this:

User select option 1. Option 1 changes the value of the variable 1 to x.
If user select option 2 later, it will change again the value of variable, but this time to y.

And so on.

The part of resize was Ok, worked fine! Thank you!

I found a "workaround" to make the dropdown to not act like a text box: changed dropdown style in properties pane to DropDownList instead just DropDown. That did the trick.

Can you or someone else explain me a little more the arguments part?
Thanks in advance!

Here is something for Arguments.

In the application you want to load with Arguments, in Form_Load add similar code.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each myCoolArg As String In My.Application.CommandLineArgs
            Select Case myCoolArg
                Case "bgSteelBlue"
                    Me.BackColor = Color.SteelBlue
                Case "bgSpringGreen"
                    Me.BackColor = Color.SpringGreen
            End Select
        Next
    End Sub

The above code is for your .exe application.

Now, to load the above .exe application and change the Background Color, all you have to do is use this code.

Process.Start("C:\Users\codeorder\Desktop\vb.net\WindowsApplication1\WindowsApplication1\bin\Debug\WindowsApplication1.exe", "bgSteelBlue")

Of course, the path of your .exe's application should be edited for the above code to work.

Also, if you create a Shortcut for your .exe application that has Argument(s) options, right click the Shortcut, select Properties, and modify the "Target" textbox to contain a blank space and your argument.

C:\Users\codeorder\Desktop\vb.net\WindowsApplication1\WindowsApplication1\bin\Debug\WindowsApplication1.exe bgSpringGreen

Hope this helps.

Hm... It helped a bit, but I still can't figure out how do it!

Here is my code 'til now:

Public Class LanguageSelectDialog
    Private Sub LanguageSelectDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle

        Dim selectedItem As Object
        selectedItem = LanguageSelect.SelectedItem

        Dim values As String

        Select Case selectedItem
            Case "value 1"
                values = "x"
            Case "value 2"
                values = "y"
            Case "value 3"
                values = "z"
        End Select
    End Sub
    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        Me.Close()
    End Sub

    Private Sub RunButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunButton.Click
        Process.Start("blank app.exe", "values")
    End Sub

    Private Sub LanguageSelect_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LanguageSelect.SelectedIndexChanged
    End Sub
End Class

I can't make it! Don't matter if I change the dropdown value, it don't change the argument. Am I doing something wrong?

Member Avatar for Unhnd_Exception

Thanks for the input on the my.application.commandlineargs: codeorder

Take your values variable out of quatation marks in the process.start

Member Avatar for Unhnd_Exception

This may help you more.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        LanguageSelect.SelectedIndex = 0

    End Sub

    Private Sub RunButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles runButton.Click
        If LanguageSelect.SelectedItem Is Nothing Then Exit Sub
        Dim values As String
        Select Case LanguageSelect.SelectedItem
            Case "value 1"
                values = "x"
            Case "value 2"
                values = "y"
            Case "value 3"
                values = "z"
            Case Else
                Exit Sub
        End Select
        Process.Start("blank app.exe", values)
    End Sub

It worked! I declared the variables as global and removed the quotes.
Now I'll try to improve the app to have more options (:

Thanks everybody!

This may help you more.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        LanguageSelect.SelectedIndex = 0

    End Sub

    Private Sub RunButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles runButton.Click
        If LanguageSelect.SelectedItem Is Nothing Then Exit Sub
        Dim values As String
        Select Case LanguageSelect.SelectedItem
            Case "value 1"
                values = "x"
            Case "value 2"
                values = "y"
            Case "value 3"
                values = "z"
            Case Else
                Exit Sub
        End Select
        Process.Start("blank app.exe", values)
    End Sub

Oh, I didn't saw your code. Sorry! The way I did worked fine, check here:

Public Class LanguageSelectDialog
    Dim lang As String
    Dim selectedItem As Object


    Private Sub LanguageSelectDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
    End Sub
    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        Me.Close()
    End Sub

    Private Sub RunButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunButton.Click
        Process.Start("braid.exe", lang)

    End Sub

    Private Sub LanguageSelect_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LanguageSelect.SelectedIndexChanged
        selectedItem = LanguageSelect.SelectedItem

        Select Case selectedItem
            Case "English"
                lang = "-language english"
            Case "French"
                lang = "-language french"
            Case "German"
                lang = "-language german"
            Case "Chinese"
                lang = "-language tchinese"
            Case "Italian"
                lang = "-language italian"
            Case "Japanese"
                lang = "-language japanese"
            Case "Korean"
                lang = "-language korean"
            Case "Portuguese"
                lang = "-language portuguese"
            Case "Spanish"
                lang = "-language spanish"
        End Select
    End Sub
End Class

Yeah, I was trying to make a language launcher for Braid. :P

Now I wish to improve the code, add more options. How can I make a checkbox functional? And how can I make a group of radio buttons functional too?

If I use more than one checkbox to have arguments, how I add it to Process.Start? I mean... more than one option, more than one argument. I thought on creating a variable that will hold all arguments, and use this variable to pass the arguments. Is this right?

Guys! Update here!
Got most of options working, the only one that I didn't figured out 'til now is the radio buttons.

Here's the code I have:

Public Class BraidLauncher
    'Declarações de variáveis
    Dim selectedItem As Object
    Dim PostProcess As String
    Dim WindowedMode As String
    Dim NoMusic As String
    Dim Vsync As String
    Dim args As String
    Dim Language As String



    Private Sub BraidLauncher_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
    End Sub

    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        Me.Close()
    End Sub

    Private Sub RunButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunButton.Click
        If PostProcessCheckbox.Checked = True Then
            PostProcess = "-no_post"
        Else
            PostProcess = ""
        End If

        If WindowedModeCheckbox.Checked = True Then
            WindowedMode = "-windowed"
        Else
            WindowedMode = ""
        End If

        If NoMusicCheckBox.Checked = True Then
            NoMusic = "-no_music"
        Else
            NoMusic = ""
        End If

        If VSyncCheckbox.Checked = True Then
            Vsync = "-no_vsync"
        Else
            Vsync = ""
        End If

        args = PostProcess & " " & WindowedMode & " " & NoMusic & " " & Vsync & " " & Language

        Process.Start("braid.exe", args)

    End Sub

    Private Sub LanguageSelect_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LanguageSelect.SelectedIndexChanged
        selectedItem = LanguageSelect.SelectedItem

        Select Case selectedItem
            Case "English"
                Language = "-language english"
            Case "French"
                Language = "-language french"
            Case "German"
                Language = "-language german"
            Case "Chinese"
                Language = "-language tchinese"
            Case "Italian"
                Language = "-language italian"
            Case "Japanese"
                Language = "-language japanese"
            Case "Korean"
                Language = "-language korean"
            Case "Portuguese"
                Language = "-language portuguese"
            Case "Spanish"
                Language = "-language spanish"
        End Select
    End Sub

End Class

Yay!

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.