Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB4,VB5,VB6
Expertise: Intermediate
Dec 9, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Quickly find which OptionButton is selected

Often OptionButton controls are arranged in control arrays. To quickly find the index of the only selected OptionButton control you can use the following code:

' assumes that the control array contains three OptionButton controls
intSelected = Option(0).Value * 0 - Option(1).Value * 1 - Option(2).Value * 2
Note that the first operand is always zero, and you can simplify the above expression as follows:

intSelected = -Option(1).Value - Option(2).Value * 2

This tip has been brought to you by Subzero Solutions, the creators of VB.IDE Macro Studio, the tool of choice for integrating with the Visual Basic IDE. Learn more at http://www.subzero-solutions.co.uk/vims
Leigh Pointer
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date