VisualBasic Make and Model ComboBox -
my goal have program able tell make selected , offer list of models based on that. however, when click combobox, execute program, , select make, not getting selections in model combobox. can me this? here source code:
option explicit on option strict on public class form1 private sub buttonexit_click(sender object, e eventargs) handles buttonexit.click close() end sub private sub form1_load(sender object, e eventargs) handles mybase.load 'initialize text property of 3 combo boxes null string comboboxmake.text = "" comboboxmodel.text = "" comboboxcolor.text = "" 'add number of cars "make" combobox. comboboxmake.items.add("honda") comboboxmake.items.add("toyota") comboboxmake.items.add("ford") comboboxmake.items.add("lexus") end sub private sub comboboxmake_selectedindexchanged(sender object, e eventargs) handles comboboxmake.selectedindexchanged dim selecteditem string selecteditem = cstr(comboboxmake.selecteditem()) 'return selected item combobox messagebox.show(selecteditem) 'display selected item end sub private sub comboboxmodel_selectedindexchanged(sender object, e eventargs) handles comboboxmodel.selectedindexchanged dim selecteditem string selecteditem = cstr(comboboxmake.selecteditem()) ' return selected item combobox if selecteditem = "honda" comboboxmodel.text = "" 'initialize text property null string comboboxmodel.items.clear() comboboxmodel.items.add("accord") comboboxmodel.items.add("civic") comboboxmodel.items.add("crv") comboboxmodel.items.add("pilot") comboboxmodel.items.add("odyssey") elseif selecteditem = "toyota" comboboxmodel.text = "" 'initialize text property null string comboboxmodel.items.clear() comboboxmodel.items.add("camrey") comboboxmodel.items.add("avalon") comboboxmodel.items.add("4runner") else comboboxmodel.items.add("not available") end if end sub end class
try using double equals when comparing string values.
Comments
Post a Comment