I am making loop to make an array of Timers and give each timer a function
here's something like what i did:
dim timer(10) as Timer
for i = 0 to 5
timer(i) = new Timer
AddHandler timer(i).Tick, Function(senderX, eX) timerFunction(i)
next
i have this function:
Private Function timerFunction(ByVal timerNo As Integer)
MsgBox(timerNo)
End Function
but i am getting 6 as the value of timerNo for every timer i call with this:
timer(3).Start()
i outputs 6 even in i change the parameter to a number from 1 to 5
why is it diong that?
timerFunction's value oftimerNois calculated at the time the function is called, not when you do theAddHandler. See ericlippert.com/2009/11/12/…