|
-
Aug 20th, 2002, 03:06 AM
#1
Thread Starter
Hyperactive Member
That's Mr Mullet to you, you mulletless wonder.
-
Aug 20th, 2002, 03:56 AM
#2
I don't think you can you'd have to call the code in the module from inside the Usercontrol.
Well actually you could pass a reference of the control to a method in the module and it could work with it from there. Make sure you clean up good though.
VB Code:
'in module
Private txt as textbox
Public Sub AttachMe(txtbx as TextBox)
Set txt=txtBox
Msgbox txt.Text
End Sub
'in usercontrol
Private Sub UserControl_Initialize()
AttachMe Text1
End Sub
It should be something along that lines, didn't test it.
Last edited by Edneeis; Aug 20th, 2002 at 03:59 AM.
-
Aug 20th, 2002, 04:04 AM
#3
Thread Starter
Hyperactive Member
It's no problem calling the code in the module, it's referencing the controls on the usercontrol that's p***ing me off. If I stop the code at runtime and look at the local variables I can see the bloody things. VB just says 'Object does not support this method...blah...blah' when I try to access Text1.Text or UserControl.Text1.Text or usrMyControl.Tex1.Text.
Just read your bit about passing it the control and that works but a single control at a time is not really an option, it's too complex for that. I'm looking for something like a form reference.
Thanks anyway, I'll just keep trying.
That's Mr Mullet to you, you mulletless wonder.
-
Aug 20th, 2002, 10:40 AM
#4
Why does the code need to be in a module? How many constituent controls are there on the Usercontrol?
For that you'd probably have to make your own control collection although that wouldn't be difficult.
You could either pass the controls collection as an object:
VB Code:
'in module
Public Sub PassCol(obj As Object)
Dim ctrls As Object
Set ctrls = obj
Dim ctrl As Control
For Each ctrl In ctrls
MsgBox ctrl.Name
Next
End Sub
'in usercontrol
PassCol Controls
Or if you don't want to use the generic object then put all the controls in your own collection:
VB Code:
'in module
Public Sub PassCol(col As Collection)
Dim ctrls As Collection
Set ctrls = col
MsgBox ctrls.Count
End Sub
'in usercontrol
Dim col As New Collection
Dim ctrl As Control
For Each ctrl In Controls
col.Add ctrl
Next
PassCol col
-
Aug 20th, 2002, 10:58 AM
#5
Thread Starter
Hyperactive Member
You beauty.
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
...Edneeis for President...
Thank you! I didn't think about passing the controls collection, I was trying to pass a reference to the whole usercontrol and dig down from there.
That's Mr Mullet to you, you mulletless wonder.
-
Aug 20th, 2002, 11:08 AM
#6
"No New Taxes!"
Glad I could help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|