Control array

Control array

Anonymous
Not applicable
174 Views
2 Replies
Message 1 of 3

Control array

Anonymous
Not applicable
Hi !

I want to create a control array for labels.

Like :

Do While i < frmMAJ.label.Count
frmMAJ.label(i).Visible = False
i = i + 1
Loop

This is working in VB but not in VBA
0 Likes
175 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
VBA doesn't support control arrays. However, you can dynamically add and
position controls.

--
Visit me at http://www2.stonemedia.com/franko

"David L. Nadeau" wrote in message
news:eeffedd.-1@WebX.SaUCah8kaAW...
> Hi !
>
> I want to create a control array for labels.
>
> Like :
>
> Do While i < frmMAJ.label.Count
> frmMAJ.label(i).Visible = False
> i = i + 1
> Loop
>
> This is working in VB but not in VBA
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
David L:
I am still trying to figure these things out.....

1) create 2 label and 1 button

Dim CtL1 As Control, CtL2 As Control
Private Sub AddAButton()
Set CtL1 = UserForm1.Controls.Add("Forms.TextBox.1", "TextBoxA", True)
CtL1.Left = 0
CtL1.top = 0
CtL1.Text = "Hello Randall"

Set CtL2 = UserForm1.Controls.Add("Forms.TextBox.1", "TextBoxB", True)
CtL2.Left = 0
CtL2.top = 30
CtL2.Text = "Thank you!"
End Sub

Private Sub CommandButton1_Click()
Label1.Caption = CtL1.Value
Label2.Caption = CtL2.Value
End Sub

Private Sub UserForm_Initialize()
AddAButton
End Sub

David L. Nadeau wrote in message ...
>Hi !
>
>I want to create a control array for labels.
>
>Like :
>
>Do While i < frmMAJ.label.Count
> frmMAJ.label(i).Visible = False
> i = i + 1
>Loop
>
>This is working in VB but not in VBA
>
0 Likes