Memberikan nilai pada saat Checkbox dicentang dan mengurangi nilai total pada saat Checkbox tidak dicentang.
Contoh Code:
Public Class frmSelectItem
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
lblTotal.Text += 1000
ElseIf CheckBox1.Checked = False Then
lblTotal.Text -= 1000
Else
lblTotal.Text = lblTotal.Text
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
lblTotal.Text += 2000
ElseIf CheckBox2.Checked = False Then
lblTotal.Text -= 2000
Else
lblTotal.Text = lblTotal.Text
End If
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
lblTotal.Text += 3000
ElseIf CheckBox3.Checked = False Then
lblTotal.Text -= 3000
Else
lblTotal.Text = lblTotal.Text
End If
End Sub
Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.Checked = True Then
lblTotal.Text += 4000
ElseIf CheckBox4.Checked = False Then
lblTotal.Text -= 4000
Else
lblTotal.Text = lblTotal.Text
End If
End Sub
Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
If CheckBox5.Checked = True Then
lblTotal.Text += 5000
ElseIf CheckBox5.Checked = False Then
lblTotal.Text -= 5000
Else
lblTotal.Text = lblTotal.Text
End If
End Sub
End Class
No comments:
Post a Comment