Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21314

Dynamic timers with dynamic Ticks

$
0
0
Point 1: Is possible make a dynamic timer with dynamic event Ticks on VB?

Ok, I know how I can make a new timer, and I know how I can add a Event, with:

Code:

AddHandler Timer1.Tick, AddressOf OnTimedEvent
AddHandler Timer2.Tick, AddressOf OnTimedEvent
.
.
AddHandler TimerN.Tick, AddressOf OnTimedEvent

With N integer.

But I want that the Event is dynamic, then I need know something of the present timer, like a name of the timer for know which variables I need to use in each case.

Easy example:

Code:

Private Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)

MsgBox(Show the name of present timer)

End Sub

Other Example:
I will have N (natural number) of timers (I dont know the N number, this will grow or decrease). I can not make N number of Events.Tick. I want make N timers and that each timer has the same Event.Tick structure, but diferent variables inside. For example: New timer1 has var "Hello", New timer2 has var "Bye", then when the timer1 call a tick event, I show Hello, when the timer2 call the same tick event, then I show Bye. How? For example with dicctionary, "timer1" = "hello", "timer2" = "bye". Then I just need know the name of timer inside the event.



Ok, maybe there is other form, but I am newbie. My work final is: Create dynamic timers, each time will have a particular Event.Tick with similar structure, but different variables.

Point 2: I need change the interval of present timer too.

Easy example:

Code:

Private Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)

MsgBox(Show the name of present timer)

TimerPresent.Interval = XXXXX

End Sub


Thanks.

Viewing all articles
Browse latest Browse all 21314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>