You are on page 1of 9

Lecture 7 : Checkbox

Check box
• Any number of check boxes can be used on a form. They work
independently.
• Its Property value could be changed in design stage manually, or in
running stage by code.
Example
• Design a form with one
text box and three check
boxes such that when
click on boxes the
following is done: change
typing to bold, italic,
underline.
Code
Private Sub Check1_Click()
Text1.FontBold = Check1.Value
End Sub
Private Sub Check2_Click()
Text1.FontItalic = Check2.Value
End Sub
Private Sub Check3_Click()
Text1.FontUnderline = Check3.Value
End Sub
Private sub form_load ()
Text1.text = “”
Check1.caption =“bold”
Check2.caption =“italic”
Check3.caption=“underline”
End sub
Running stage
Example
• Design a form with one list
box and three check boxes
and three text box as shown
in the figure
• The process of the program
that when click on checkbox
will insert what written in
text3 into list1 while when
click on checkbox2 will
insert what written in text3
into list1 while when click
on checkbox3 will insert
what written in text3 into
list1
Code
• Private Sub Check1_Click() • Private Sub Check3_Click()
• If Check1.Value = 1 Then • If Check3.Value = 1 Then
• List1.AddItem (Text1.Text) • List1.AddItem (Text3.Text)
• End If • End If
• End Sub • End Sub

• Private Sub Check2_Click() • Private Sub Form_Load()


• If Check2.Value = 1 Then • Text1.Text = ""
• List1.AddItem (Text2.Text) • Text2.Text = ""
• End If • Text3.Text = ""
• End Sub • End Sub
Running stage

You might also like