vb.net - Show Combobox selected item in textbox -
public class form1 public selected integer private sub combobox1_selectedindexchanged(byval sender system.object, byval e system.eventargs) handles combobox1.selectedindexchanged select case combobox1.selecteditem case "philippines (php)" selected = 1.0 case "united states(usd)" selected = 45.2 case "japan(jpy)" selected = 0.36 case "canada(cad)" selected = 35.01 case "australia(aud)" selected = 33.34 end select end sub private sub textbox1_textchanged(byval sender system.object, byval e system.eventargs) handles textbox1.textchanged textbox1.text = combobox1.selecteditem end sub end class
please dont laugh casually reading basic tutorial in vs2010.. problem here nothing selected item in combobox shows in textbox..
firstly, 'selected' variable wrong type. needs string or double type. string if it's going used readability , double if intend on using in calculation.
public selected double private sub combobox1_selectedindexchanged(byval sender system.object, byval e system.eventargs) handles combobox1.selectedindexchanged ' call tostring() method text. select case combobox1.selecteditem.tostring() case "philippines (php)" selected = 1.0 case "united states(usd)" selected = 45.2 case "japan(jpy)" selected = 0.36 case "canada(cad)" selected = 35.01 case "australia(aud)" selected = 33.34 end select ' need catch if selected variable has not value set. textbox1.text = selected.tostring() end sub
Comments
Post a Comment