Monday, June 8, 2009

VB Day Seven (7) Check Box

Check box is another very good item that is used for multiple selection.

For Example you have filling a form and need to fill that which courses you have done so far then there may be a person who haven't done any course or may be multiple courses those are given in the list then he must select more than one options.

so you can make more than one selections from a list of Check Boxes. when you click once it becomes checked and when you click it again, it becomes unchecked.



lets start it practically



Drag three Check Boxes a label and a command button

the default name of check box will be checkbox1, checkbox2 etc so rename them with Chk1 Chk2 and Chk3



also rename the label as lblResult
now i want to show that which checkboxes you have selected

goto click event of Command button and do the code as


if chk1.value=True and Chk2.Value=True and Chk3.Value=True then
LblResult.Caption="You have Checked 1,2 and 3"

elseif Chk1.Value=True and Chk2.Value=True and Chk3.Value=False then
LblResult.Caption="You have Checked 1 nad 2"

elseif Chk1.Value=True and Chk2.Value=False and Chk3.Value=True then
LblResult.Caption="You have Checked 1 nad 3"

elseif Chk1.Value=True and Chk2.Value=False and Chk3.Value=False then
LblResult.Caption="You have Checked 1"

elseif Chk1.Value=False and Chk2.Value=False and Chk3.Value=True then
LblResult.Caption="You have Checked 3"

elseif Chk1.Value=False and Chk2.Value=True and Chk3.Value=False then
LblResult.Caption="You have Checked 2"

elseif Chk1.Value=False and Chk2.Value=True and Chk3.Value=True then
LblResult.Caption="You have Checked 2 and 3"

End if


this was just to show you that you can make multiple selection.

No comments:

Post a Comment