JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Getting a Checkbox's State

You've added all the checkboxes you need to your new program, WinBigSuperCasino, and you've connected those checkboxes to Click event handlers. But now there's a problem—when the user sets the current amount of money they want to bet, you need to check if they've exceeded the limit they've set for themselves. But they set their limit by clicking other checkboxes—how can you determine which one they've checked?

You can see if a checkbox is checked by examining its Checked property. This property can be set to either True or False. Here's an example; in this case, I will change a button's caption if a checkbox, CheckBox1, is checked, but not otherwise:

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    If CheckBox1.Checked Then
        Button1.Text = "The check mark is checked"
    End If
End Sub
Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor