View Single Post
Old Apr 23rd, 2007, 8:59 AM   #4
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 237
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
Quote:
Originally Posted by randum77 View Post
The only part that I wouldn't know right off is how to make the property name dynamic. The rbYes is what I mean. Would i declare it as rbYes(i) or something like that? I appreciate the help.
well, you could give them names IF you knew how many you were going to have, then you could hardcode them in, but since you could have anywhere form 1 to 100, this is inconvenient, redundant, and not very efficient coding to do it this way.


instead, what you probably want to do is this, just keep adding them like so

vbnet Syntax (Toggle Plain Text)
  1. rbYes = New RadioButton()
  2. rbYes.Left = 8
  3. rbYes.Top = 300
  4. Me.Controls.Add(rbYes)
  5. rbYes.Text = "YES"

now when you want to access it you can do something like this or some variation of it.

vbnet Syntax (Toggle Plain Text)
  1. 'iterate through every radiobutton control on the form
  2. For Each rb As RadioButton In Me.Controls
  3. If (rb.Checked) Then
  4. MsgBox(rb.Text & " was checked!!!")
  5. End If
  6. Next

you can also get to a control through its index (ex: me.controls(2))
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote