140 likes | 160 Views
Welcome with Ifs. Add a ComboBox and give it a name (e.g. cboLanguauge). Click next to the Items property and then the ellipsis button that results. Use the String Collection Editor dialog box to enter the language names. Result so far.
E N D
Click next to the Items property and then the ellipsis button that results.
Use the String Collection Editor dialog box to enter the language names.
Set the Text property to “English” (the ComboBox will now start with an entry)
btnOK_Click subroutine uses If to establish different behavior in different cases
Structure of an If If cboLanguage.Text = "English" Then lblMessage.Text = "Welcome" End If If, Then and End are keywords the establish the structure of the If statement Between If and Then comes a condition – an expression that evaluates to True or False Between the line starting with If and the End If line comes a statement or set of statements to be executed provided the condition is true and is ignored should the condition be false
Result User forgot to click OK button
Return to Design view and double click on the ComboBox The ComboBox has a SelectedIndexChanged event and we will put our code here and eliminate the button altogether
Result: Somewhat improved with no button for user to forget to click