|
こんなのでは?
「Sub UserForm_Initialize」で各LabelのTagプロパティにCaptionをセットして置きます
但し、「Sub ListBox1_Change」でTextBoxを「.Value = ""」の時「.Enabled = True」に
しているので、TextBoxがロックされて入力出来なくなります
これの解除は如何するの?
Option Explicit
Private vntPos As Variant
Private Sub UserForm_Initialize()
Dim i As Long
vntPos = Array("1", "3", "5")
ListBox1.List = Array("AAA", "BBB", "CCC")
Label1.Tag = "あああ"
Label3.Tag = "いいい"
Label5.Tag = "ううう"
For i = 0 To UBound(vntPos)
With Me.Controls("Label" & vntPos(i))
.Caption = .Tag
End With
Next i
End Sub
Private Sub ListBox1_Change()
Dim i As Variant
For i = 0 To UBound(vntPos)
With Me
If .Controls("TextBox" & vntPos(i)).Value <> "" Then
' .Controls("TextBox" & vntPos(i)).Enabled = True
With .Controls("Label" & vntPos(i))
.Caption = .Tag
End With
Else
' .Controls("TextBox" & vntPos(i)).Enabled = False
.Controls("Label" & vntPos(i)).Caption = ""
End If
End With
Next i
End Sub
|
|