Click to See Complete Forum and Search --> : Instantiating objects from ActiveX dll


Ghost308
August 7th, 2001, 10:51 AM
This isn't any major problem, I'm just wondering if someone can explain this a little clearer than I understand it...

I have compiled an ActiveX dll that has a couple functions for calculating Time statistics. The class is called TimeStats. When I create an object of that class I have to use


Dim ts as Object
set ts = new TimeStats




Everything works fine from there. I'm just wondering why I can't use..


Dim ts as TimeStats




..because this is legal syntax but gives a run-time error 91 (object not set). Like i said, my code is working and everyone is happy, but can someone explain why I can't dimension the object directly? Thank you!!

Jeff

michi
August 7th, 2001, 11:36 AM
Did you try this:

Dim ts as YourDll.TimeStats

Regards,

Michi

Ghost308
August 7th, 2001, 11:40 AM
Hi, thanks for replying!

I tried that but it still gives the same error. I do have the dll checked in References. My code works just fine if I dim the variable as Object then set it to New TimeStats. I'm just trying to understand why I have to do it that way. Thank you though for the input!

Jeff

Clearcode
August 7th, 2001, 11:55 AM
Have you tried the shorthand:

Dim ts as new TimeStats




HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.

Ghost308
August 7th, 2001, 12:00 PM
Thanks, that sure works alright- I just still don't understand why the "New" keyword is required.