On May 02, 2007, at 03:12 UTC, Rubber Chicken Software Co. wrote:

> >I'd suggest copying the control array (which is not an array at all)
> >to an array, and passing the array to the function.
> 
> But that defeats the purpose, which is to wrap the task of finding 
> out which Radio Button is selected without writing the If/Select in 
> every case.

No it doesn't, if you use a general function to copy the control array
into a real array, which you can then pass to a generic function.  The
trouble here will be type safety -- what type should this array be?  If
it's "Control()" then you won't be able to pass it to a function that
expects RadioButton().

So you may be better off just writing your function this way:

Protected Sub DoSomething(rb As RadioButton)
  // Find the index of the radio button in the same array as rb
  // which is currently selected.
  Dim index As Integer = -1
  Dim w As Window = rb.Window
  for i As Integer = 0 to w.ControlCount - 1
    if w.Control(i).Name = rb.Name and _
      RadioButton( w.Control(i) ).Value then
      index = w.Control(i).Index
    end if
  next
  // ...now, do something with index  
End Sub

Now you can just pass in any example of that control array (including
"me" in the Action event), and it'll find the index of the one that's
selected.  This works by using Control.Window to find what window it's
on, searching the controls of that window for others with the same
name, and then using their Index property to get the value of interest.

Best,
- Joe


--
Joe Strout -- [EMAIL PROTECTED]
Strout Custom Solutions

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to