INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

Code Links

Use Contol Arrays for better option buttons by MrMoocow
Posted: 28 Jul 01

<-Revised->
Many newbies will place multiple option buttons and write code for each one. This will explain the easiest and most effiecent way.

Step One:
Make an option but, name it and caption it as you like.

Step Two:
Right click it and select Copy

Step Three:
Right click the form or frame you want the next control to be, and select paste.

-> It will ask if you want to create a control array, Select yes.

Repeat three as many times as nessacary.

Now double click any one of those option buttons.

It should be now in the code view,

Each of those option buttons has the property index too, now heres how you set the code for each of them..

your code so far should look like this..

Private Sub Option1_Click(Index As Integer)

End Sub

now if you have two option buttons heres what it would look like...


Private Sub Option1_Click(Index As Integer)

Select Case Index
Case 0
msgbox "Option 1"

Case 1
Msgbox "Option 2"

end select

End Sub

This code cuts down on the number of subs and will speed up your programs.


www.moosoft.cjb.net

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close