Results 1 to 2 of 2

Thread: Object Creation Problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    3

    Object Creation Problem

    I'm using VB6, and I'm creating a Class Module to hold various data. With that, I want to have a couple Timer objects in the Class Module. The problem is, I declare an object of data type Timer. Then after that, I'm not sure how come I can't set it. The only way it seems like it will work is if I set the variable an already existing Timer object on another form. But of course, doing that would defeat the purpose of having the Timer variable in the Class Module.

    To better explain this here is what I have so far:

    Code:
    Public tmrCount As Timer
    Then when the class intializes, I would like the object to be created for use. There must be a way to set the object so it can be used without using a Timer on another Form. So is this possible in VB6?

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Object Creation Problem

    Timer is not a regular object or variable type: it is a control. You can't have a control contained in a Class Module, controls can only be on forms.

    As for what you can do... humm... take a look at SelfSub. I don't have it in my fresh memory at the moment, but I think you can use it's timer feature to create a timer in a Class Module. I'm not sure if SelfSub itself has the timer code, probably not, but the other related code that comes with it should have what you're looking for.

    Other solution would be to use API timers (which is what I guess the other code included with SelfSub sources use, but you can simplify to only the required code with some work vs. the simplicity offered by SelfSub, without probably really understanding how it all works).

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