RAYLWARD102
Well-known Member
- Joined
- May 27, 2010
- Messages
- 529
Can it be done?
Let say I create 200 labels on a user form; 100 of which are C1.labelzA and 100 of which are C1.labelzB
Later on, would klike to iterate through controls and find controls from c1.labelzA; who to do that without using names???
Let say I create 200 labels on a user form; 100 of which are C1.labelzA and 100 of which are C1.labelzB
Code:
Private Sub UserForm_Initialize()
Dim x As Long
Set MEM1 = New Collection
For x = 1 To 100
Set LAB = UserForm1.Controls.Add("Forms.Label.1")
With LAB
.Caption = ""
.Height = 100
.Width = 500
.Left = 0
.Top = 0
.SpecialEffect = fmSpecialEffectFlat
.Name = "labelA" & x
.Font.size = .Height * 0.5
.BackStyle = fmBackStyleOpaque
.BackColor = vbWhite
.ForeColor = RGB(192, 192, 192)
.TextAlign = fmTextAlignCenter
Set C1 = New PlatformControls
Set C1.labelzA = LAB
MEM1.Add Item:=C1, Key:=.Name
End With
Set LAB = UserForm1.Controls.Add("Forms.Label.1")
With LAB
.Caption = ""
.Height = 100
.Width = 500
.Left = 0
.Top = 0
.SpecialEffect = fmSpecialEffectFlat
.Name = "labelB" & x
.Font.size = .Height * 0.5
.BackStyle = fmBackStyleOpaque
.BackColor = vbWhite
.ForeColor = RGB(192, 192, 192)
.TextAlign = fmTextAlignCenter
Set C1 = New PlatformControls
Set C1.labelzA = LAB
MEM1.Add Item:=C1, Key:=.Name
End With
Next x
End Sub
Later on, would klike to iterate through controls and find controls from c1.labelzA; who to do that without using names???
Code:
For Each CNTRL In UserForm1.Controls
If "control event name is labelza" Then
End If
Next CNTRL