vb.net - Using a Select Statement Based on Check Box Being Checked -


firstly homework assignment working on, couldn't work way. had complete assignment using if statements. objective build form user fill out submit order. there 3 check boxes (one burgers, 1 fries, , drinks). if check 1 of boxes group box become visible containing radio buttons make selection want.

i wanted try use select statement based on if check box had been checked. use different cases each of radio buttons. if run program , click 1 button supplied populate dblcost variable first case available. below code. want understand doing wrong or if isn't feasible way of approaching problem. below code wanted use:

public class frmrestaurantorder  private sub checkedchanged(sender object, e eventargs) handles cbxburgers.checkedchanged, cbxfries.checkedchanged, cbxdrinks.checkedchanged      if (cbxburgers.checked)         gbxburgers.visible = true     else         gbxburgers.visible = false     end if      if (cbxfries.checked)         gbxfries.visible = true     else         gbxfries.visible = false     end if      if (cbxdrinks.checked)         gbxdrinks.visible = true     else         gbxdrinks.visible = false     end if  end sub  private sub btncompute_click(sender object, e eventargs) handles btncompute.click      dim dblcost double = 0      select case gbxburgers.visible = true         case rbtregularburger.checked             dblcost += 4.19         case rbtcheeseburger.checked             dblcost += 4.79         case rbtbaconburger.checked             dblcost += 4.79         case rbtbaconcheeseburger.checked             dblcost += 5.39         case else             dblcost += 0     end select      select case cbxfries.checked = true         case rbtsmallfries.checked             dblcost += 1.29         case rbtlargefries.checked             dblcost += 1.59         case else             dblcost += 0     end select      select case cbxdrinks.checked = true         case rbtsoda.checked             dblcost += 1.69         case rbtwater.checked             dblcost += 1.49         case else             dblcost += 0     end select      txtcost.text = formatcurrency(dblcost)  end sub 

end class

i think understanding of select case little off. take @ this , see if helps.


Comments