Reference RunTime Control

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!
 
R

rowe_newsgroups

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
 
P

Phill W.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top