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 controlsintSelected = 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 athttp://www.subzero-solutions.co.uk/vims
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.
























