CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Instantiating objects from ActiveX dll

    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


  2. #2
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: Instantiating objects from ActiveX dll

    Did you try this:

    Dim ts as YourDll.TimeStats

    Regards,

    Michi

  3. #3
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Re: Instantiating objects from ActiveX dll

    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


  4. #4
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Instantiating objects from ActiveX dll

    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.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  5. #5
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Re: Instantiating objects from ActiveX dll

    Thanks, that sure works alright- I just still don't understand why the "New" keyword is required.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured