tags:

views:

31

answers:

2

I created a skeleton Active X DLL with its Instancing property set to MultiUse and only one function which does nothing but pop up a message box saying that it has been called.

Then I created a test program and added the DLL to its References.

I added code to declare a variable of the DLL's Classmodule, to create a new object and to call the function.

In all cases I used Intellisense code completion, so VB6 certainly about the DLL and it's class & method.

However, when I run the tester it reports runtime "error 91 object variable or With block variable not set" when trying to create the New object.

This is new territory for me, so hopefully it is something obvious.


Update: I added a message box in a DLL fn() to say that it had been called, then went to a real life web site that uses Active X to call into the DLL and saw the message box - but I still get the error in a VB tester application(!?)

+1  A: 

Try changing the function in your active x dll to return a message instead. Show your message box in your calling code, not in the dll.

Else, try in command prompt, regsvr32 "myDll.dll", and then run your code.

neolace
+1 thanks for replying. I did register the DLL (although VB should probably do that for me). I don't think it matters where the message box is, as it doesn't get that far - it blows up creating the new object
Mawg
Thanks 4 the +1, It does matter as the message box can't be displayed from inside the dll, only from the calling vb6 app. check the following:http://us.generation-nt.com/q-problem-displaying-messagebox-inside-foxpro-dll-c-plus-plus-window-help-21365272.html
neolace
Try option 10 on http://www.daniweb.com/forums/thread17300.htmlopen control panel->compnent servicesconsole root->comp services-> my computers>com+ applictions - drag and drop your dll into the window.
neolace
+1  A: 

It would be easier to find the problem if you could post the calling code and the DLL class.

Here's a guess. Have you remembered the Set on the line that creates the new object?

Correct code

Set obj = New MyDLL.MyObject

Incorrect code

obj = New MyDLL.MyObject
MarkJ
d'oh! d'oh! d'oh!
Mawg
It's easy to forget! Especially since it's not needed in vb.net.
MarkJ