×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Control Arrays

Control Arrays

Control Arrays

(OP)

I need to know how to pass a control array into a sub or function.
I have 5 subs for every control, but the logic is identical.
The only thing that changes is the control reference. For example:

Private Sub RemoveCol(ByVal rTake As Integer)
Dim intCnt As Integer
Dim intC As Integer
intC = lblCol.count

Do While lblCol.count > (intC - rTake)
intCnt = lblCol.count
If intCnt = 1 Then Exit Sub
Unload lblCol(intCnt)
Loop

End Sub

It would save me a lot of work if I could use a sub like this:

Private Sub RemoveCTL(ctl as control, ByVal rTake As Integer)
Dim intCnt As Integer
Dim intC As Integer
intC = ctl.count

Do While ctl.count > (intC - rTake)
intCnt = ctl.count
If intCnt = 1 Then Exit Sub
Unload ctl(intCnt)
Loop

End Sub

But it doesn't work.
Is it possible with VB6?

RE: Control Arrays

I haven't tested this but try this. Instead of passing as control, pass it as object type.
example:
Private sub RemoveCTL(ctl as Object, ByVal rTake as Integer)

RE: Control Arrays

Or you could also use,

Private sub RemoveCTL(ctl as variant, ByVal rTake as Integer)

Does Work for me!!

Anand

RE: Control Arrays

or even

Private sub RemoveCTL(ctl As Control, ByVal rTake as Integer)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close