Help with AddHandler for a Timer

I try to create a very simple application with no window.
There is a timer created in the code.
I try to use AddHandler to send the action of the Timer to a method called FTP_registre, but I get and error “This item doesn’t exist”.
In fact when I try to write Temporitzador.Action I have no AutoComplete, so I suppose the error is here. But I have AutoComplete when I set properties (Enabled, Period)
This is the code:

[code]Dim Temporitzador as new Timer
Temporitzador.Enabled = True
Temporitzador.Period = 60 * 60 * 1000

AddHandler Temporitzador.Action AddressOf FTP_registre[/code]

Please tell me what’s wrong in it.


Dim Temporitzador as new Timer AddHandler Temporitzador.Action, AddressOf FTP_registre Temporitzador.Period = 60 * 60 * 1000 Temporitzador.Mode = Timer.Mode<?>

You’ll also need

Sub FTP_registre(Sender As Timer) #Pragma Unused Sender . . . End Sub

I always set the handler before properties in this case the mode activates the timer so having the handler there first seems safer.

Hi Ramon,

First, you are missing a comma (at least in the code you posted here):

AddHandler Temporitzador.Action, AddressOf FTP_registre

And second, in the declaration of the method (FTP_registre) you should have:

Sub FTP_registre(sender As Timer)

Check the LR (I am sure you did, but have a look at the example and how the “handler” is declared:


EDIT: Wayne beat me to it…

Thank you Wayne and Julen.
I was sure I forgot something, because I had used it before, but I tried with LR and I could not find this stupid missing.