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!!!!
Printable View
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!!!!
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.
Why do you need to do that? If you put a timer on your form at design time and leave its Interval at 0 it will just sit there and not do anything until you need it.
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.Quote:
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??
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.
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:
Public Declare Function GetTickCount Lib "kernel32" () As Long Dim lngTicks As Long lngTicks = GetTickCount ' The code for the process to be timed goes here Debug.Print GetTickCount - lngTicks
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!