I'm using VB.net and I'm having trouble trying to add different values when I select checkboxes and diplaying the total in a textbox. When unchecking them, it should be subtracting the values. Here is my code
"totals" is my textbox
Dim total As Double
Private Sub cchstk_CheckStateChanged(sender As Object, e As EventArgs) Handles cchstk.CheckStateChanged
If (cchstk.Checked = True) Then
total = total + 109.99
totals.Text = Double.Parse(total)
ElseIf (chstk.Checked = False) Then
total = total - 109.99
totals.Text = Double.Parse(total)
End If
End Sub
Private Sub cms_CheckStateChanged(sender As Object, e As EventArgs) Handles cms.CheckStateChanged
If (cms.Checked = True) Then
total = total + 79.99
totals.Text = Double.Parse(total)
ElseIf (chstk.Checked = False) Then
total = total - 79.99
totals.Text = Double.Parse(total)
End If
End Sub
Private Sub prrdg_CheckStateChanged(sender As Object, e As EventArgs) Handles prrdg.CheckStateChanged
If (prrdg.Checked = True) Then
total = total + 49.99
totals.Text = Double.Parse(total)
ElseIf (chstk.Checked = False) Then
total = total - 49.99
totals.Text = Double.Parse(total)
End If
End Sub
Private Sub gb_CheckStateChanged(sender As Object, e As EventArgs) Handles gb.CheckStateChanged
If (gb.Checked = True) Then
total = total + 29.99
totals.Text = Double.Parse(total)
ElseIf (chstk.Checked = False) Then
total = total - 29.99
totals.Text = Double.Parse(total)
End If
End Sub
Private Sub nd_CheckStateChanged(sender As Object, e As EventArgs) Handles nd.CheckStateChanged
If (nd.Checked = True) Then
total = total + 29.99
totals.Text = Double.Parse(total)
ElseIf (chstk.Checked = False) Then
total = total - 29.99
totals.Text = Double.Parse(total)
End If
End Sub`