|
こんにちは。
参考までに。
'=====フォームのモジュールに==========================
Private MyLabels() As String 'test2用
Private Sub UserForm_Click()
' Call test1
Call test2
End Sub
'test2の場合
Private Sub UserForm_Initialize()
Dim ctrl As MSForms.Control
Dim i As Long
With Me
For Each ctrl In .Controls
If ctrl.Name Like "lbl*" Then
ReDim Preserve MyLabels(i)
MyLabels(i) = Mid(ctrl.Name, 4)
i = i + 1
End If
Next
End With
End Sub
Sub test2()
Dim i As Long
For i = LBound(MyLabels) To UBound(MyLabels)
With Me.Controls("lbl" & MyLabels(i))
.BackColor = &H8000000F
.Caption = MyLabels(i)
End With
Next
End Sub
Sub test1()
Dim ctrl As MSForms.Control
With Me
For Each ctrl In .Controls
If ctrl.Name Like "lbl*" Then
ctrl.BackColor = &H8000000F
ctrl.Caption = "1"
End If
Next
End With
End Sub
'===================================================================
では。
|
|