| | |
If, Else, and ElseIf in VB Button
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 35
Reputation:
Solved Threads: 0
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
'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:
vb Syntax (Toggle Plain Text)
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 Last edited by cometburn; Feb 22nd, 2008 at 2:02 am.
Proud to be Philippine made...
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.
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.
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
•
•
Join Date: Jan 2008
Posts: 35
Reputation:
Solved Threads: 0
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?
Last edited by leokuz; Feb 22nd, 2008 at 3:22 am. Reason: To clarify and correct typo error
•
•
Join Date: Jan 2008
Posts: 35
Reputation:
Solved Threads: 0
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.
•
•
Join Date: Jan 2008
Posts: 35
Reputation:
Solved Threads: 0
•
•
•
•
What do you mean by first statement? the first value of the combobox?
'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
Last edited by leokuz; Feb 22nd, 2008 at 3:37 am. Reason: to better explain
•
•
Join Date: Jan 2008
Posts: 35
Reputation:
Solved Threads: 0
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.
Last edited by leokuz; Feb 22nd, 2008 at 3:41 am. Reason: to explain better
![]() |
Similar Threads
- how to get 1 submit button to validate user's choice (ASP)
- Create Paint Brush's Fill Color (VB.NET)
- Fill Color (VB.NET)
- Radio Button If Statement (PHP)
- examples of code for option button (Visual Basic 4 / 5 / 6)
- Problem passing value from radio button to second page. (PHP)
- Create Windows Authentication (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: adodb
- Next Thread: I need a help about VB 6 -> reason
Views: 6297 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





