|
-
Feb 14th, 2001, 10:39 AM
#1
Thread Starter
New Member
I am creating a dll with a public class, that I want to accept a textbox object as a byref parameter in a public procedure. This produces a compile error stating that I cannot use private module objects as parameters or return types in public module procedures. This is the type of error I would expect if the parameter was a class object that had its instancing set to private. Can anyone explain why this is occurring here, and hopefully with a solution?
-
Feb 15th, 2001, 04:21 AM
#2
Fanatic Member
Well
You can pass control references to DLL's but you will probably have to declare it as a Control rather than it's specific control name.
As for why you can't, I'm not too sure.
-
Feb 15th, 2001, 04:36 AM
#3
Fanatic Member
Yeah, I had problems with this sort of thing a while back, I had to bite the bullet and endure late binding in this case and used code like this:
Code:
Public Function Tester(tB As Object) As Long
If TypeOf tB Is TextBox Then
Debug.Print tB.Text
'Do other bits here
Tester = 0
Exit Function
Else
Debug.Print "NOT A TEXTBOX"
Tester = -1
Exit Function
End If
End Function
I know its not great, but I didn't have the time to mess around.
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Feb 15th, 2001, 05:06 AM
#4
Fanatic Member
Heres a slimy way of getting round it:
Pass an object pointer (to the textbox) to a public function, then resolve the pointer, and do whatever you want - mail me : [email protected], and i'll send you a sample project.
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Feb 19th, 2001, 07:52 AM
#5
Thread Starter
New Member
Cheers for help guys.
I've sorted it by passing in the textbox as an object, and then setting a privately declared textbox to the object which gets passed in. This works ok as long as the object is validated as a textbox first.
I still don't understand why it has to be done in this manner - I'm sure there's a VERY good reason (hmmm).
-
Feb 20th, 2001, 12:00 PM
#6
Member
I know why
I had this exact problem when I was developing a VB app. In it, I passed a combo box to an ActiveX dll, to load it with information.
The program would not compile, for the reason you stated above.
Fortunately, I was working at Microsoft at the time, in the Visual Studio department, so I asked them about this.
They said it had to do with passing a private class into another thread. (or something like that).
To get around this, I passed the combo box as an object, and was able to make it work.
If you create a module, in the same project, then you can pass a text box into a subroutine in the module.
However, if the module is located in a different ActiveX dll/exe, then there is a threading problem. A dll is supposed to run in the same thread as the module it works with, but it is supposed to create very unstable code, that could cause problems. If you were working with an ActiveX exe, then you would get even more problems, because it runs in its own thread.
If you do this, could you use a Mutex to make sure the program doesn't crash?
Samwise Galenorn
[email protected]
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
|