Microsoft Office Tutorials and References
In Depth Information
Try It
figurE 21-12
Private Sub OptGroup_Click()
MsgBox _
“Hello, my name is “ & OptGroup.Name & “.” & vbCrLf & _
“My caption is “ & OptGroup.Caption & “.”, _
vbInformation, _
“You just clicked me, here’s my info :”
End Sub
If this were an actual workbook project, you would not need a Message Box
to tell you which OptionButton was just clicked. More realistically, you might
assign a String type variable to the selected OptGroup.Caption if that caption
string is needed as part of an operation elsewhere in your project.
13.
Return to the UserForm module. At the top of the module, identify which OptionButtons you
want to be grouped into the OptGroup class. For this example, the first five OptionButtons
will be grouped, so create an instance of the OptGroup class with the New keyword for the
Class1 module name:
Dim optButtons(1 To 5) As New Class1
14.
The UserForm’s Initialize event is a good opportunity to do the actual grouping of the
five OptionButtons. From the Object drop-down list select UserForm, and in the Procedure
drop-down list select Initialize. VBA will enter the UserForm_Initialize and End Sub
statements with an empty space between the two lines, as follows:
Private Sub UserForm_Initialize()
End Sub
 
Search JabSto ::




Custom Search