Hello! I m struggling with this button and/or code to work. The button with Process.Start opens any folder I want if I do not use Ifs and Elses, but I do need to open folder based on user selection of name in the combobox and one choice from two radio buttons. Can someone help? I am knew not just to VB but to programming as a whole (I am doing it with VB Express Edition 2008) Thank you.

'Open folder pertaining to current person and task
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

If ComboBox1.Text = "Lastname, Firstname" Then
If RadioBtn1.Checked = True Then
Process.Start("C:\Employee Records\City\State1\Lastname, Firstname\2008")
Else
If ComboBox1.Text = "Lastname, Firstname" Then
If RadioBtn2.Checked = True Then
Process.Start("C:\Employee Records\City\State2\Lastname, Firstname\2008")
Else
End If
End If
End If
End If

If ComboBox1.Text = "Lastname2, Firstname" Then
If RadioBtn1.Checked = True Then
Process.Start("C:\Employee Records\City\State1\Lastname2, Firstname\2008")
Else
If ComboBox1.Text = "Lastname2, Firstname" Then
If RadioBtn2.Checked = True Then
Process.Start("C:\Employee Records\City\State2\Lastname2, Firstname\2008")
Else
End If
End If
End If
End If

End Sub


'the list would repeat many times

try to modify your code like:

If ComboBox1.Text = "Lastname, Firstname" Then
            If RadioBtn1.Checked = True Then
                Process.Start("C:\Employee Records\City\State1\Lastname, Firstname\2008")
            ElseIf RadioBtn2.Checked = True Then
                Process.Start("C:\Employee Records\City\State2\Lastname, Firstname\2008")
            Else
            End If
ElseIf ComboBox1.Text = "Lastname2, Firstname" Then
           If RadioBtn1.Checked = True Then
                Process.Start("C:\Employee Records\City\State1\Lastname2, Firstname\2008")
            ElseIf RadioBtn2.Checked = True Then
                Process.Start("C:\Employee Records\City\State2\Lastname2, Firstname\2008")
            Else
            End If
End If
if combo1.text <> "" then
    If RadioBtn1.Checked = True Then
          Process.Start("C:\Employee Records\City\State1\" & combo1.text &"\2008")
    Else
          Process.Start("C:\Employee Records\City\State2\" & combo1.text &"\2008")
    end if
end if

you have posted your thread in wrong forum.
this forum is intended to visual basic 6 only.

move your thread from here and re-post it in vb.net forum. then only your question will be answered.

hope you got it.

ryan_vietnow Wow! With your modification it works for second, third, etc. employees/names, but when I choose name that corresponds to first block/statement and click button nothing happens. Why do you think first statement (should I say block?) doesn't work?

you have posted your thread in wrong forum.
this forum is intended to visual basic 6 only.

move your thread from here and re-post it in vb.net forum. then only your question will be answered.

hope you got it.

Thank your for explaining this to me, and will do that of course (this is my first posting on this website), but since couple people already started helping me here and with some success then I'll wait couple more reply if it's OK. Thanks again.

What do you mean by first statement? the first value of the combobox?

cometburn I have tried your way, but nothing happens. I'll check more maybe typo on my part.

What do you mean by first statement? the first value of the combobox?

I mean when I choose in my form person "Lastname, Firstname" that mentioned in the very begining of the code (following part) nothing happens:

'this part does not work
If ComboBox1.Text = "Lastname, Firstname" Then
If RadioBtn1.Checked = True Then
Process.Start("C:\Employee Records\City\State1\Lastname, Firstname\2008")
ElseIf RadioBtn2.Checked = True Then
Process.Start("C:\Employee Records\City\State2\Lastname, Firstname\2008")
Else
End If
'but this next part works when I click button
ElseIf ComboBox1.Text = "Lastname2, Firstname" Then
If RadioBtn1.Checked = True Then
Process.Start("C:\Employee Records\City\State1\Lastname2, Firstname\2008")
ElseIf RadioBtn2.Checked = True Then
Process.Start("C:\Employee Records\City\State2\Lastname2, Firstname\2008")
Else
End If
End If

What do you mean by first statement? the first value of the combobox?

Actually you said it better. Yes, when I choose the first value of the combobox and click button nothing happens (and yes I clicked one of the radio buttons also), but it may be important for you to know that the first value of combobox is also mentioned in the begining (first part) of code.

Never mind, the code does work. I don't know what I typed wrong first time, but I have copied the second part of working code to the first part and renamed directories (folders) and names and it works now very well. Thank you ryan_vietnow very much for help (it is your code that works) and all of you who replied to my post so quickly. I will surely want to come back again in the near future for your help guys. God bless!!!

God bless you too.

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.