|
-
Dec 27th, 2006, 05:54 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Passing Control Arrays
I have these five Sets of control arrays:
lblComponent() (0to3)
lblTheme() (0to2)
lblClock() (0to1)
lblClickWheel (only 1)
lblContacts() (0to1)
These are menu items, and I am moving these items from right to left and vice versa, so basically I am just using the Left, Right, Width and Visible properties. I am using a timer to move the items.
What I want to know is that is there any possible method to pass these control arrays (i.e their names, and the upper bound values). It would be a lot easier for me to be able to pass these control arrays and it would save me a lot of repetitive coding.
Thanx for your help in advance
Hey... If you found this post helpful please rate it.

-
Dec 27th, 2006, 06:03 PM
#2
Re: Passing Control Arrays
Do you want to pass the actual control arrays or just "their names, and the upper bound values"?
-
Dec 27th, 2006, 06:08 PM
#3
Re: Passing Control Arrays
If it's the former then you can perhaps build on this.
VB Code:
Private Sub Command1_Click()
MySub Text1 ' a control array
End Sub
Public Sub MySub(CtlArray As Variant)
MsgBox CtlArray.Count
End Sub
-
Dec 27th, 2006, 06:23 PM
#4
Re: Passing Control Arrays
I've always used Variant as MartinLiss showed.
-
Dec 27th, 2006, 06:23 PM
#5
Thread Starter
Hyperactive Member
Re: Passing Control Arrays
I want to pass the control arrays itself... Heres An Example
VB Code:
Private Sub tmrTimer_Timer()
Call Procedure(send all the members of a certain control array)
End Sub
Public Sub Procedure(lblLabel As Label)' Recieve All The Members of the Array
Dim intCount As Integer
For intCount = 1 to X 'The Upper Bound Value
lblLabel(intCount).Left = lblLabel.Left - 507
Next intCount
End Sub
The timer gets enabled when a command button is clicked.
The Question is, how do I send the name of the array and the number of members in the array. And how do I recieve it?
Last edited by khanjan_a2k; Dec 27th, 2006 at 06:27 PM.
Hey... If you found this post helpful please rate it.

-
Dec 27th, 2006, 06:35 PM
#6
Thread Starter
Hyperactive Member
Re: Passing Control Arrays
Oh I actually used your procedure Martin and it worked out fine. I just added the following line to get the upperbound value
VB Code:
Dim intUB As Integer
intUB = CtlArray.Count - 1
Thanx a lot.
Hey... If you found this post helpful please rate it.

-
Dec 27th, 2006, 06:42 PM
#7
Re: [RESOLVED] Passing Control Arrays
You can also pass it as a String:
VB Code:
Option Explicit
Private Sub Command1_Click()
MySub "Label1" 'control array name...
End Sub
Private Sub MySub(sControl As String)
Dim N As Long
For N = Me.Controls(sControl).LBound To Me.Controls(sControl).UBound
Me.Controls(sControl)(N).Caption = N 'or something...
Next N
End Sub
-
Dec 28th, 2006, 06:06 AM
#8
Re: [RESOLVED] Passing Control Arrays
I would pass the control array As Object rather than As Variant
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
|