I don't recall ever having to do this before, but I'm trying to pass an array of optionbuttons to a function and I can't get it to work. Maybe I'm just retarded, but could someone please post the appropriate syntax for this? Thanks.
Printable View
I don't recall ever having to do this before, but I'm trying to pass an array of optionbuttons to a function and I can't get it to work. Maybe I'm just retarded, but could someone please post the appropriate syntax for this? Thanks.
Sadly you'll need to pass the array in as a variant:
VB Code:
Public Function TheFunction(Byval OptionButtons As Variant) ' Hope and pray that the Variant is the array you're looking for ' Error handling would be a good thing to have here OptionButtons(0).Value = True End Function
Sick. The one thing I didn't try.:rolleyes:
Except don't pass it ByVal (use ByRef instead)
You may also pass an Index.
whats wrong with...
VB Code:
Private Sub F(OptionButtons() As OptionButton) End Sub
That won't work because VB will expect an parameter to be passed (which can be done when you want to deal with the whole array).
If you want to pass your array ByRef you don't have to explicitly code that. ByRef is the default.
I know. But it's good practice to explicitly state what you're doing.Quote:
Originally posted by Hack
If you want to pass your array ByRef you don't have to explicitly code that. ByRef is the default.
Not necessary.