Radio Button and Checkbox

Radio button or option button, is a circular control that comes in a group with other controls of the same type. Usually a radio button like an empty circle or a donut. If it is clicked, it will be filled with a big dot. And in every group of radio button only one can be selected by the user. Example in a membership form, there is always a radio button for Gender for Male and Female. Example: Visual Basic Code:
  1. 'check if the selected radiobutton is male
  2. If RadioButton1.Checked = True Then
  3. 'display that the selected radio button is Male
  4. MsgBox("Your Gender is Male")
  5. 'check if the selected radiobutton is Female
  6. ElseIf RadioButton2.Checked = True Then
  7. 'display that the selected radio button is Female
  8. MsgBox("Your Gender is Female")
  9. End If
CheckBox is quite opposite and similar to Radio Button, because using CheckBox you can do a multiple selection, and unlike the Radio button you can only select one, and it is similar in some way. Example their properties, they have the same Checked property that when selected, will toggle the true or false value. Example: Visual Basic Code:
  1. 'check if cappucino is selected
  2. If CheckBox1.Checked = True Then
  3. MsgBox("You selected Cappucino")
  4. End If
  5. 'check if Latte is selected
  6. If CheckBox2.Checked = True Then
  7. MsgBox("You selected Latte")
  8. End If
  9. 'check if Hot Coffee is selected
  10. If CheckBox3.Checked = True Then
  11. MsgBox("You selected Hot Coffee")
  12. End If
  13. 'check if Ice Cold Coffee is selected
  14. If CheckBox4.Checked = True Then
  15. MsgBox("You selected Ice Cold Coffee")
  16. End If

Comments

Submitted byAnonymous (not verified)on Sun, 01/10/2021 - 04:39

Thank you.

Add new comment