passing name of control Array to a Routine

I need to pass a name of controlArray to a Routine, so that i do not have to repeat the code every time i am using to set some of the  controlArray properties

Whe i tried to do this i am getting an error message "Invalide property  Assignemnet"

My code looks like this:

This is my control Array click event:
Private sub lblTemp_Click(Index as Integer)
    DoSomething lblTemp, Index
End Sub

This is the routine where i want to pass the control array name:
Private Sub Procedure DoSomething(lblLabel as Label, _
      idx as Integer)
      lblLabel(idx).caption = "Hello World"
End Sub
svenkatapuramAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
Try this:

'This is my control Array click event:
Private Sub lblTemp_Click(Index As Integer)
    DoSomething lblTemp, Index
End Sub

'This is the routine where i want to pass the control array name:
Private Sub DoSomething(lblLabel, idx As Integer)
      lblLabel(idx).Caption = "Hello World"
      lblLabel(idx).BackColor = vbRed
End Sub

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crazymanCommented:
D00D try this

Private Sub lblTemp_Click(Index As Integer)
DoSomething lbltemp(Index)
End Sub

Private Sub DoSomething(lblLabel As Label)
lblLabel.Caption = "Hello World"
End Sub

you have to pass the label with its index because just the label name refers to no specific label
0
psmith789Commented:
Have you tried defining
DoSomething(lblLabel as Object, ....

and/or calling the application by using
  DoSomething lblTemp(Index), Index
0
svenkatapuramAuthor Commented:
Thanks,

it did work
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.