I am trying to add only my selected values but its only adding the first selected value in my list repeatedly to the amount of selected items. can someone help me with this?
for example, lets say I check off 2 in my list. than I check off three other boxes are inline after 2's box in my list not before. no matter what value is in those boxes I still get 8. 2+2+2+2
for example, lets say I check off 2 in my list. than I check off three other boxes are inline after 2's box in my list not before. no matter what value is in those boxes I still get 8. 2+2+2+2
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load lblAnswer.Text = "" ListBox1.Items.Clear() ''add up prices from list Dim total As Decimal Dim i As Int32 For i = 0 To CheckBoxList1.Items.Count - 1 If CheckBoxList1.Items(i).Selected Then total += Decimal.Parse(CDec(CheckBoxList1.SelectedValue.ToString)) ListBox1.Items.Add(CheckBoxList1.SelectedValue) End If Next lblAnswer.Text = total End Sub End Class
Comment