Download Lab Session 01 - NED University

Transcript
Engineering Workshop
Lab Session 14
NED University of Engineering & Technology – Department of Computer & Information Systems Engineering
subsequently set the value of a different button in the group to True, the one that was True will
automatically become False.
You can use option buttons in two basic ways in code

Use the click event if you want to take an action when users select an option. This method is
useful when you are using option buttons that are in a control array as in the following
example:
Private Sub optWash_Click (Index as Integer)
Select Case Index
Case 0
MsgBox
“You selected: Normal”
Case 1
MsgBox “You selected: Heavy Duty”
Case 2
MsgBox “You selected: Pots and Pans”
End Select
End Sub

Do not write any code in the option button events. Instead, use an if statement to check their
state, as shown here:
Private Sub cmdStartWash_Click( )
If optHeavy = True Then
DoHeavyWash
Else
DoNormalWash
Endif
End Sub
This second method is useful if you do not want something to happen immediately when users
select options.
It is possible to have multiple option buttons on a form selected at the same time. For this, you
have to separate the option buttons into groups by using container controls. Using a container,
such as the Frame, allows you to group option buttons.
EXERCISES
1.
Differentiate between check box and option buttons with the help of examples.
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
79