|
-
Oct 18th, 2002, 01:53 PM
#1
Thread Starter
New Member
How do you pass an array of controls to a function?
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.
-
Oct 18th, 2002, 02:01 PM
#2
Frenzied Member
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
-
Oct 18th, 2002, 02:30 PM
#3
Thread Starter
New Member
Sick. The one thing I didn't try.
-
Oct 18th, 2002, 03:33 PM
#4
Software Eng.
Except don't pass it ByVal (use ByRef instead)
-
Oct 18th, 2002, 03:38 PM
#5
PowerPoster
You may also pass an Index.
-
Oct 18th, 2002, 06:53 PM
#6
Fanatic Member
whats wrong with...
VB Code:
Private Sub F(OptionButtons() As OptionButton)
End Sub
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Oct 18th, 2002, 07:18 PM
#7
Software Eng.
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).
-
Oct 18th, 2002, 07:21 PM
#8
If you want to pass your array ByRef you don't have to explicitly code that. ByRef is the default.
-
Oct 18th, 2002, 07:27 PM
#9
Software Eng.
Originally posted by Hack
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.
-
Oct 18th, 2002, 09:14 PM
#10
PowerPoster
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|