On May 1, 2007, at 11:12 PM, Rubber Chicken Software Co. wrote:
> At 12:30 PM 5/1/2007, you wrote:
>
>>> How do you pass Control Arrays to a external function?
>>>
>>> I am dealing with the classic simple task of finding which Radio
>>> Button is selected, and wrapping that up in a function.
>
>> 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. I have such a function in VB.
>
> In VB a control array isn't really an array either, but you can pass
> it in a function. So my wrapper functions in VB is feasible and saves
> code, which is the entire purpose. With RB you can't, and of course
> any attempt to make it work (as suggested by others) defeats the
> purpose; the whole point is to wrap the capability.
>
> How do YOU do that in RB? Or is it possible (practically)?
>
I think that I told you. You'll need to add a function to your
window like
Function GetRadioButton1List() as RadioButton
dim theList() as RadioButton
dim index as Integer = 0
while RadioButton1(index) <> nil
theList.Append RadioButton1(index)
index = index + 1
wend
return theList
End Function
I don't know a generic way to do this part.
Once you have the array, the remaining code is generic.
Function Selected(theList() as RadioButton) as RadioButton
dim theSelectedButton as RadioButton = nil
for each button as RadioButton in theList
if button.Value then
theSelectedButton = button
exit
end if
next
return theSelectedButton
End Function
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>