![]() |
Module Access
I am making a new usercontrol. I need to access the usercontrol's label which is named lable1
How could I access it from a standard module(.bas) My usercontrol's name is bob :
|
You need to expose label1 in the usercontrol.
Put this in the UserControl: :
Public Property Get MyLabel() As Object:
UserControl1.MyLabel.Caption = "hello" |
omg, thank you so much rory, you have no idea how long i spent looking for this.
|
No probs!
|
uh-oh whenever I run the program, i get this error:
With Variable or Object Variable not set. |
This code seems to work for me...
:
Public Property Get MyLabel() As Label |
no here is what happens. I call this in my module:
UserControl1.MyLabel.Caption = "hello" I am actually using this in a moudule. |
Then you need Form1.[name of control].MyLabel.Caption = "hello"
What VB is trying to do is reference the class rather than the instance on a form, which can't be done. Let's say I had a usercontrol called ctlMyWidget. The default name for the control when I put it on a form would be ctlMyWidget1. As you're using UserControl1 for the class name, the default name is actually UserControl11 , which is where the problem is. |
ok..as soon as I get home I will test it. Thxs once again rory.
Also, why won't it let me use APIs I put an API in my code and it says,: User-Type not defined. And highlights the API.. My Visual Basic is such as POS! |
Your question about the API: My gues is you're using an API such as GetCursorPos that uses a custom type in its argument list. In this case, the custom POINTAPI type is used:
:
Public Type POINTAPILook through the specific API declaration for any user defined types and ensure you have them defined in code as well. If you can't find their definition, googling for articles on the API in question will usually also provide the necessary types as well. |
| All times are GMT -5. The time now is 5:28 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC