Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 1st, 2005, 10:25 PM   #1
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
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

 
 sub bobcall() 
 bob.label1.caption
doesn't seem to work. NEED HELP PLEASE!
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Apr 2nd, 2005, 9:54 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
You need to expose label1 in the usercontrol.
Put this in the UserControl:
Public Property Get MyLabel() As Object
Set MyLabel = UserControl.Label1
End Property
Public Property Set MyLabel(ByRef NewLabel As Label)
Set UserControl.Label1 = NewLabel
End Property
Then you can do
UserControl1.MyLabel.Caption = "hello"
Rory is offline   Reply With Quote
Old Apr 3rd, 2005, 1:44 PM   #3
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
omg, thank you so much rory, you have no idea how long i spent looking for this.
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Apr 3rd, 2005, 8:39 PM   #4
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
No probs!
Rory is offline   Reply With Quote
Old Apr 5th, 2005, 9:24 AM   #5
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
uh-oh whenever I run the program, i get this error:

With Variable or Object Variable not set.
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Apr 5th, 2005, 2:26 PM   #6
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
This code seems to work for me...
Public Property Get MyLabel() As Label
Set MyLabel = UserControl.Label1
End Property
Public Property Set MyLabel(ByRef NewLabel As Label)
Set UserControl.Label1 = NewLabel
End Property
That kind of error doesn't seem to be possible anywhere in this code: are you sure it's an error with that particular bit?
Rory is offline   Reply With Quote
Old Apr 5th, 2005, 3:47 PM   #7
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
no here is what happens. I call this in my module:

UserControl1.MyLabel.Caption = "hello"

I am actually using this in a moudule.
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Apr 5th, 2005, 3:56 PM   #8
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
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.
Rory is offline   Reply With Quote
Old Apr 6th, 2005, 10:00 AM   #9
Cipher
Hobbyist Programmer
 
Cipher's Avatar
 
Join Date: Feb 2005
Location: /home/cipher
Posts: 123
Rep Power: 4 Cipher is on a distinguished road
Send a message via AIM to Cipher Send a message via MSN to Cipher
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!
__________________
And there was much rejoicing... Yay....
Cipher is offline   Reply With Quote
Old Apr 6th, 2005, 4:23 PM   #10
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
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 POINTAPI
x as long
y as long
End Type

Look 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.
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC