Reference RunTime Control

  • Thread starter Thread starter Joseph Gruber
  • Start date Start date
J

Joseph Gruber

Hi All. I must be missing something but I can't figure out how to do
this. In my form's onload event I am adding a label control at
runtime. I create the control by calling a sub that is in a module
that has the necessary code to create the label. This works fine but
later I want to resize this label -- how can I reference the label
that I created in the onload?

Thanks!
 
Hi All. I must be missing something but I can't figure out how to do
this. In my form's onload event I am adding a label control at
runtime. I create the control by calling a sub that is in a module
that has the necessary code to create the label. This works fine but
later I want to resize this label -- how can I reference the label
that I created in the onload?

Thanks!

One option would be to use Me.Controls.Find("labelName").

Thanks,

Seth Rowe
 
Joseph said:
In my form's onload event I am adding a label control at
runtime. I create the control by calling a sub that is in a module
that has the necessary code to create the label.

A Label is an instance of an Object, just like any other.

Make your "AddALabel" Sub into a /Function/ and return the Label you
create and put on the Form:

Function AddALabel( frm As Form ) as Label
lbl = New Label
. . .
Return lbl
End Function

Save this value somewhere:

Dim dynLabel as Label _
= module1.AddALabel( Me )
This works fine but later I want to resize this label
how can I reference the label that I created in the onload?

Use the value you stored when the Label was created.

dynLabel.Size = New Size( 99, 99 )

HTH,
Phill W.
 
Back
Top