|
-
Mar 17th, 2003, 04:04 AM
#1
Thread Starter
Addicted Member
DLL Error
In my DLL i get the following error during compilation if i pass a form as a parameter to any procedures. The following is an eg..
'The following declaration throws me an error while compiling
Public Sub GetFormName(frm as Form)
Msgbox frm.Name
end sub
'The following declaration does not throw me an error
Public Sub GetFormName(frm as Object)
Msgbox frm.Name
end sub
During compilation of the dll it throws a follwing error.. I do not know how to get rid of it or what is wrong in my DLL generation.. Please help me to solve this problem.. If i change the declaration from a Form to an object it does not throw me an error but it also does not recognise any properties of a valid Form object..
The following is the error it throws....
"Private object modules cannot be used in public object modules as parameters or return types for public procedures, as public data members, or as fields of public user defined types."
-
Mar 17th, 2003, 05:42 AM
#2
Hyperactive Member
These examples work fine for me :
Form1
Code:
Dim testDLL As Class1
Private Sub Command1_Click()
Set testDLL = New Class1
Set testDLL.testfrm = Form1
testDLL.GetFormName Form1
testDLL.GetFormNameToo
End Sub
DLL Class1
Code:
Public testfrm As Form
Public Sub GetFormName(frm As Object)
MsgBox frm.Name & "-" & frm.Caption, , "GetFormName sub"
End Sub
Public Sub GetFormNameToo()
MsgBox testfrm.Name & "-" & testfrm.Caption, , "GetFormNameToo sub"
End Sub
I'm not sure if I can give a full explanation about the error but I think it is to do with the fact that the Form in your exe is private and therefore cannot be passed to a public class module as a parameter, you have to do a late bound call to the object instead of explicitly declaring its type.
I think anyway!
Hope this helps in some way 
---
Anglo Saxon
-
Mar 20th, 2003, 07:51 AM
#3
Junior Member
The error is because it has found a data type used by your form that isn't declared as either Multiuse, GlobalMultiuse or PublicNotCreatable.
For example, having a property on your form
Public Property Get MyStuff() As clsMyStuff
But having the declartion of clsMyStuff as Private (instead of Multiuse) will cause this error.
By using Object instead, VB can't check the interface for any absent declarations and assumes it's ok.
Dave
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
|