Home
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
 
 
 
 
TitleDynamically create OptionButtons at run time using Load
KeywordsOptionButton, Load, runtime
CategoriesControls
 
Use Load to create the new OptionButton. Set its Container property to place it inside the appropriate container. Position the control, set its Caption property, and make it visible.
 
Private Sub Form_Load()
    ' Load flavors.
    Load optFlavor(1)
    InitOptionButton optFlavor(1), optFlavor(0), "Vanilla"

    Load optFlavor(2)
    InitOptionButton optFlavor(2), optFlavor(1), _
        "Strawberry"

    Load optFlavor(3)
    InitOptionButton optFlavor(3), optFlavor(2), "Pistachio"

    ' Load colors.
    Load optColor(1)
    InitOptionButton optColor(1), optColor(0), "Green"

    Load optColor(2)
    InitOptionButton optColor(2), optColor(1), "Blue"

    ' Select initial options.
    optFlavor(3).Value = True
    optColor(2).Value = True
End Sub

' Position the OptionButton below opt_above
' in the same container.
Private Sub InitOptionButton(ByVal opt As OptionButton, _
    ByVal opt_above As OptionButton, ByVal txt As String)
    opt.Container = opt_above.Container
    opt.Move opt_above.Left, _
        opt_above.Top + opt_above.Height + 120
    opt.Caption = txt
    opt.Visible = True
End Sub
 
 
Copyright © 1997-2001 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated