Dovberman
asked on
How to Pass a Control Group as a Procedure Parameter
I have a group of picture controls and command buttons on a form. I need to pass the control groups to a Sub or Function.
This is my code:
ScanGroup me.picCards(), me.cmdPickOne
Sub ScanGroup(ppicCards() as PictureBox, pcmdPickOne() as Control)
Dim intCtr1 as integer
For intCtr1 to ppicCards.Count - 1
If ppicCards(intctr) = pintCritical Then
'Do something
Exit For
End If
Next intCtr1
For intCtr1 to pcmdPickOne.Count - 1
If pcmdPickOne(intctr) = pintCritical Then
'Do something
Exit For
End If
Next intCtr1
When I try to compile, I get a type mismatch error. This comes from an incorrect parameters statement.
I can pass arrays with no problem.
What is different about control groups?
What am I doing wrong ?
Thanks,
Dovberman
This is my code:
ScanGroup me.picCards(), me.cmdPickOne
Sub ScanGroup(ppicCards() as PictureBox, pcmdPickOne() as Control)
Dim intCtr1 as integer
For intCtr1 to ppicCards.Count - 1
If ppicCards(intctr) = pintCritical Then
'Do something
Exit For
End If
Next intCtr1
For intCtr1 to pcmdPickOne.Count - 1
If pcmdPickOne(intctr) = pintCritical Then
'Do something
Exit For
End If
Next intCtr1
When I try to compile, I get a type mismatch error. This comes from an incorrect parameters statement.
I can pass arrays with no problem.
What is different about control groups?
What am I doing wrong ?
Thanks,
Dovberman
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I do use Option Explicit in all my code. Not shown in the snippet.
Thanks for the prompt reply.
Dovberman