Add a label at runtime

  • Thread starter Thread starter Guest
  • Start date Start date
I don't know if you can do this, but you could create a label beforehand
with a blank caption then use Label1.Caption = "Test label" at runtime to
populate it.
 
Dim newCtl As msforms.Control
Set newCtl = Me.Controls.Add("Forms.Label.1")
newCtl.Caption = "New Label"

With newCtl
.Left = 100
.Top = 50
.Visible = True
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
If by form, you mean a userform:

Private Sub UserForm_Initialize()
Dim LBL As MSForms.Label
Set LBL = Controls.Add("Forms.Label.1", "Lable2", True)
LBL.Top = 5
LBL.Left = 5
LBL.Caption = "abcd"

End Sub
 
Back
Top