Results 1 to 6 of 6
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Application.OnTime usage (2000 sp-3/ 98SE)

    I have written some timer procedures that work fine from a standard module, but not from a class module. The basic problem appears to be (my) inability to reference the macro, which now "lives inside" the class as a Private method:
    <code>
    Sub StartTimer()
    ....
    Application.OnTime NextTime, "StartTimer" <font color=448800>' Call recursively</font color=448800>
    ....
    End Sub
    </code>
    The error message says:
    The macro ''C:<path><filename>.xls'!StartFlash' cannot be found.
    Clearly, XL is looking for it in one of the standard modules. I have been unable to find the right way to reference it from inside the class module. Advice appreciated.

    Alan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Application.OnTime usage (2000 sp-3/ 98SE)

    You can't call a method of a class using OnTime, only a procedure in a standard module. So you'll have to move part of your code out of the class module.

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Application.OnTime usage (2000 sp-3/ 98SE)

    Why not built a whole new timer class?
    PS: Just being naughty Alan! <img src=/S/wink.gif border=0 alt=wink width=15 height=15>
    Regards,
    Rudi

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application.OnTime usage (2000 sp-3/ 98SE)

    <P ID="edit" class=small>(Edited by AlanMiller on 18-Aug-05 01:31. )</P>Actually, there's an API implementation I've seen around the traps somewhere. I might give it a test drive if I can find it.
    [Edited] - Right here in fact.

    Alan

  5. #5
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Application.OnTime usage (2000 sp-3/ 98SE)

    Wow...and I was just about to wish you good luck in your attempts to find it!
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Regards,
    Rudi

  6. #6
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application.OnTime usage (2000 sp-3/ 98SE)

    <P ID="edit" class=small>(Edited by AlanMiller on 18-Aug-05 20:42. Now explained.)</P> <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15> I was kind of afraid of that. So much for encapsulation! Thanks Hans.

    Alan

    [Edit] - Well, I had to try out the API solution, but now I understand a bit better, why it can't work. The call uses the AddressOf operator, which is where VB coughs. According to the Help file:
    "Although you can use AddressOf to pass procedure pointers among Basic procedures, you can't call a function through such a pointer from within Basic. This means, for example, that a class written in Basic can't make a callback to its controller using such a pointer. "

    The whole problem appears to be caused by the way in which VB only partially implements pointer functionality. Prior to this, I could see no valid reason (thinking in C++ terms) why it couldn't work. Anyway, this means that as usual, you were rrrr... rrrii... rrrright. <img src=/S/heavy.gif border=0 alt=heavy width=40 height=34>

    Alan

Posting Permissions

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