ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add a label at runtime (https://www.excelbanter.com/excel-programming/347283-add-label-runtime.html)

Ron

Add a label at runtime
 
Hi,

Can anyone tell me how I can add a label to a form at runtime.


Regards,
Ron.

Ian

Add a label at runtime
 
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.

--
Ian
--
"Ron" wrote in message
...
Hi,

Can anyone tell me how I can add a label to a form at runtime.


Regards,
Ron.




Bob Phillips[_6_]

Add a label at runtime
 
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)


"Ian" wrote in message
...
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.

--
Ian
--
"Ron" wrote in message
...
Hi,

Can anyone tell me how I can add a label to a form at runtime.


Regards,
Ron.






Tom Ogilvy

Add a label at runtime
 
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

--
Regards,
Tom Ogilvy

"Ron" wrote in message
...
Hi,

Can anyone tell me how I can add a label to a form at runtime.


Regards,
Ron.





All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com