listbox - how to add a specific value from a list box in vb.net? -
how can retrieve total price listbox , total in textbox?? code add data listbox
private sub cbitem_selectedindexchanged(byval sender object, byval e system.eventargs) handles cbitem.selectedindexchanged if cbitem.selectedindex < 0 return dim price = convert.todecimal(items(cbitem.selectedindex, 1)) txtitemprice.text = price end sub private sub btnadd_click(byval sender system.object, byval e system.eventargs) handles btnadd.click dim price = convert.todecimal(txtitemprice.text) dim quantity = convert.toint32(txtquantity.text) dim totalprice integer = price * quantity lstorder.items.add(cbitem.selecteditem & vbtab & vbtab & vbtab & price & vbtab & vbtab & vbtab & quantity & vbtab & vbtab & totalprice) end sub
suppose have 2 controls : listbox1 , textbox1.
' initialise textbox 0 textbox1.text = 0 ' insert values in listbox listbox1.items.add(1) listbox1.items.add(2) listbox1.items.add(3) listbox1.items.add(4) ' each item in listbox integer = 0 listbox1.items.count - 1 textbox1.text = textbox1.text + listbox1.items(i) next
for work, have price of current item , multiply it's quantity. or can sum each item of totalprice column.
Comments
Post a Comment