Results 1 to 8 of 8

Thread: Create Timer control at runtime

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    70

    Question Create Timer control at runtime

    How do you create a Timer control at runtime? Is it possible??

    Basically, I want to create a Timer control array element on the fly.

    Thanks!!!!

  2. #2
    New Member
    Join Date
    Oct 2002
    Location
    Oxfordhsire, UK
    Posts
    13
    Have a look at using the load keyword.

    for example something like

    load timer(x)

    NOTE: You will need to have a timer already on the grid with the index property set to 0.

    Each time you want to have another timer control you just call the Load Timer(x) and set x at a new value.

    Hope this helps

    Steve.

  3. #3

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    70
    Thanks Steve, I'll give that a try.

    Martin, I'm using a flexgrid where everytime a new row is added a timer(x) control is created.

    Do I need to drop as many timer controls on the form that is equal to the number of array elements??

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    Originally posted by Jason Carden
    Thanks Steve, I'll give that a try.

    Martin, I'm using a flexgrid where everytime a new row is added a timer(x) control is created.

    Do I need to drop as many timer controls on the form that is equal to the number of array elements??
    Needing a separate timer for each row of a grid seems very strange. What is it that you are doing? If you do need to generate timers you only need to put one on the form, but make sure to set its Index to 0. Then as SteveG suggested you just Load MyTimer(1) or 2 or or 999, one at a time, as you need them.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    70
    Thanks. Does sound strange!! I have to keep track of the elapsed time from a timestamp of "time" for each row. I could not find a simple function in vb that could do this. "Timediff" would be perfect but that's in Visual C++. I thought about converting.

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    The DateDiff function can be used for that, but if you really want to time a process, the thing to use is GetTickCount
    VB Code:
    1. Public Declare Function GetTickCount Lib "kernel32" () As Long
    2.  
    3.     Dim lngTicks As Long
    4.  
    5.     lngTicks = GetTickCount
    6.     ' The code for the process to be timed goes here
    7.     Debug.Print GetTickCount - lngTicks

  8. #8
    Addicted Member
    Join Date
    Nov 2000
    Location
    San Diego - California
    Posts
    251
    Just have one timer running at a smaller inteval and increment an array of counters, each one belonging to a row in the flexigid.

    You could use the .rowitem in the flexigrid as the counter. Then you call a sub that check each counter/.rowitem in the flexigrid. if one has exceeded a set period , reset the counter and continue with the service of that row.

    I hope the explaination is clear.

    Goodluck!

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