how do i create a timer within a class during runtime when the user clicks a button? I want the tick sub to be in the class if possible? so basically, can you add a timer to something other than a form?
Printable View
how do i create a timer within a class during runtime when the user clicks a button? I want the tick sub to be in the class if possible? so basically, can you add a timer to something other than a form?
Yes.
VB Code:
Dim x As New Timer AddHandler x.Tick, AddressOf mytickhandlingsub Private Sub mytickhandlingsub(ByVal sender As Object, ByVal e As System.EventArgs) 'do your stuff here End Sub
thanks. that works. is there a way to pass arguments to the tick function though? thanks again.
Tick is not a function its an event and so you can't really pass arguments to it. It gets raised by the timer object itself so only the timer itself passes any arguments to it.
yeah. i figured that, but thanks for clarifying.