I'm trying to implement (i.e. implement an interface) a class in VB 6, but I'm getting this error: "Compile Error: Bad interface for Implements: Interface contains data fields". So I'm wondering if there are any limitations on which class you can implement? Or if anyone know why I'm getting this specific error, that would be helpful as well.
Let me know if I need to be more clear. Tha开发者_如何学Cnks guys.
Dave
Interfaces in VB6 can only include methods, not member variables.
You can simulate a member variable by implementing a property method (with let and get functions).
VB's type library constructor has MANY limitations on it. there's probably a parameter used in that interface that isn't compatible with what VB is cool with, for instance, an unsigned long. VB CAN handle unsigned longs, you just have to put them in a normal LONG variable and then treat them a little differently because of the sign.
So, you're best bet would be use OLE view to open the type library where this interface is defined, copy it out into an IDL file by itself and then recompile it with MIDL after modifying the interface definition to be more friendly with VB.
Matthew Curland discusses this in his VB6 book "Power techniques for Everyday programs."
精彩评论