|
-
May 1st, 2000, 05:16 AM
#1
Hello all,
I have a User Defined Type which can hold information about an Employee. I just don't know where exactly to declare it.
If I declare in it a standard module, and try to reference it, I get the following error:
Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions.
If I declare the UDT on a class module of a (second) project added to the current group, it's working. (I also added a reference to the DLL created by this second project).
If I declare my UDT in a class module on the first project, I get the same error. So where should I declare the UDT if I am not using the DLL from the second project??
Imar
[Edited by Imar on 05-02-2000 at 12:19 AM]
-
May 1st, 2000, 05:25 AM
#2
Hyperactive Member
Lmar,
It sounds like you are trying to pass your UDT into the procedure as a variant.
If your procedure looks like this now:
Public Sub MyProcedure (something)
'somestuff here
End Sub
Try changing it to something like:
Public Sub testproc(something as MyType)
'somestuff here
End Sub
"People who think they know everything are a great annoyance to those of us who do."
-
May 1st, 2000, 05:34 AM
#3
I'm afraid that's not the case. I am trying to add the UDT to a Dictionary Object, and the error occurs on the .add method of the Dictionary Object.
However, the error doesn't occur when the UDT is declared in a class module of a seperate DLL.
"In Holland I would say to this: Ra Ra Politiepet" :-)
Any suggestions??
imar
-
May 1st, 2000, 05:44 AM
#4
Hyperactive Member
If you're using VB6, there's a circular dependency bug that MS hasn't released a fix for yet (that I know of... which ain't much). It's listed under Q190198.
SYMPTOMS: When your project contains modules that are heavily dependent upon each other for variable definitions (such as a constant being the type of another module, or passing a UDT defined in one module to another), editing one module will gradually cause MS Visual Basic to fail.
-
May 1st, 2000, 05:59 AM
#5
Mongo,
I looked up the KB article, but this is not the case either. VB doesn't crash, I just get a run-time error.
Thanks for your reply.
Imar
-
May 1st, 2000, 06:08 AM
#6
Hyperactive Member
It's not run-time Error -2147417848(80010108), by any chance?
-
May 1st, 2000, 06:19 AM
#7
I guess it has to do with that one, because I've seen that one come around a few times. But unfortunately I can't recall for which situation exactly.
The "Only user-defined types....." error appears as a compile error.
Why?? Do you know a solution??
Imar
-
May 1st, 2000, 06:26 AM
#8
Hyperactive Member
I don't know exactly what's causing your problem; but Q223116 listed that run-time code as being related to an error that can be fixed with SR3. Hope it helps.
-
May 1st, 2000, 06:33 AM
#9
Must be Bad-Karma-Day for me I'm afraid. :-( This KB article is not exactly related to my problem. Besides, I have upgraded to Service Pack 3.
Maybe I should rephrase my question: Where do I have to declare my UDT's so I can use them anywhere in my application AND be able to add them to a dictionary object?
Thanks for your help so far.
Imar
-
May 1st, 2000, 06:51 AM
#10
Hyperactive Member
Well, seems more like I'm batting 1000 for you. Don't mean to be handing you red herrings and running you astray. That said, I'll take my third swing. *smirk*
What about your version of DCOM? (he asked, feeling mostly wind on his bat.) There's a typically cryptic comment in the ReadMe:Part1 file on the CDROM that mentions updating your version of DCOM... (Still hoping for joy in Muddville)
-
May 1st, 2000, 07:13 AM
#11
Frenzied Member
I've had this problem too, I was taught that it was bad programming practice to pass a udt out of a class module, you should pass all the bits out a seperate properties, if you need one for an API you only need to pass out the pointer(use VarPtr) UDT asre allways passed byref, just pass thepointer byval, it does the same thing.
If it wasn't for this sentence I wouldn't have a signature at all.
-
May 1st, 2000, 06:27 PM
#12
The thing is, I am not passing my UDT outside any class module.
I just want to declare a UDT in a standard module, and use it there:
create a few UDT's, add them to a dictionary object and then use that dictionary object somewhere else in my application.
I haven't checked my DCOM version yet, but I can't imagine that's the problem. My software is rather up-to-date: Windows 2000, Visual Studio 6 Service Pack 3, ADO 2.5 etc.
Where does one normally declare a (public) UDT?? In a standard module, right??
And then where is it available? In a form?? In another module?? I'd say that should be the case.
Imar
-
May 1st, 2000, 11:14 PM
#13
Hyperactive Member
-
May 2nd, 2000, 01:43 AM
#14
Sam, LG, Mongo and others,
Thanks for your suggestions, but I still can't get it to work. Actually I am not passing any UDT outside my module, and I am also not using late binding on an Active X server.
I'll try to explain the whole situation:
I have a very simple UDT holding an ID and a String, named GSCError. (Actually what it is and how it looks should not be important, this should be a principle thing).
When I declare my UDT in a module, then create a few variables of type GSCError in another module or form, things work OK. When for example I try to retrieve the string from the UDT, no problem. However, when I try to add my UDT to a dictionary object (I tried both the following methods:
Dim dobjMyErrors As New Scripting.Dictionary
and
Dim dobjMyErrors As Scripting.Dictionary
Set dobjMyErrors = CreateObject("Scripting.Dictionary")
)
I get a compile error (see posts from before).
As far as I am concerned, I can add any data to a dictionary object, but apparently not this one.
If I declare my UDT in another ActiveX DLL, to which I have a reference and which is part of my project-group, no error occurs.
Whooaaaaaaaaahhhh, what is going on??? :-)
Somebody please help. I can't imagine this can't be solved.
Imar
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
|