Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim timer As New Timer
Dim textbox As New TextBox
Me.Controls.Add(textbox)
timer.Interval = 100
timer.Tag = textbox
AddHandler timer.Tick, AddressOf timer_Tick
timer.Start()
End Sub
Private Sub timer_Tick(sender As Object, e As EventArgs)
Dim t As Timer = DirectCast(sender, Timer)
DirectCast(t.Tag, TextBox).Text = Now.ToString("HH:mm:ss")
End Sub
works just fine with me.. the sender Object in the Tick Eventhandler is allways the caling Timer.
+ sender is Object is has no Tag Property itself.. you need to cast it to your specific Type.. In this case,
Timer