Hi all. I'm looking for some help here. My app creates a runtime
label which is used as a clock -- it also then creates the timer for
this clock at runtime. When the timer tick's clockUpdate is called
(through AddHandler) and I use Controls.Find to find the runtime
label. This works somewhat except that it seem for every 3 out of 4
ticks the following error is thrown: A first chance exception of type
'System.IndexOu tOfRangeExcepti on' occurred in mscorlib.dll
Any ideas why? Sample code is below. Both of these subs, and the
code that builds the runtime controls are in a seperate module from
the forms.
Thanks
Sub buildTimer(ByVa l timer As System.Windows. Forms.Timer)
timer.Enabled = True
timer.Interval = 500
AddHandler timer.Tick, AddressOf clockUpdate
End Sub
Sub clockUpdate(ByV al sender As Object, ByVal e As System.EventArg s)
Dim valLocalTime As System.Windows. Forms.Label = Nothing
Dim frm As System.Windows. Forms.Form =
System.Windows. Forms.Form.Acti veForm
Try
valLocalTime = frm.Controls.Fi nd("valLocalTim e", True)(0)
Catch ex As Exception
End Try
If Not valLocalTime Is Nothing Then valLocalTime.Te xt =
My.Computer.Clo ck.LocalTime.To String("HH:mm:s s") & " EDT"
valLocalTime = Nothing
frm = Nothing
End Sub
label which is used as a clock -- it also then creates the timer for
this clock at runtime. When the timer tick's clockUpdate is called
(through AddHandler) and I use Controls.Find to find the runtime
label. This works somewhat except that it seem for every 3 out of 4
ticks the following error is thrown: A first chance exception of type
'System.IndexOu tOfRangeExcepti on' occurred in mscorlib.dll
Any ideas why? Sample code is below. Both of these subs, and the
code that builds the runtime controls are in a seperate module from
the forms.
Thanks
Sub buildTimer(ByVa l timer As System.Windows. Forms.Timer)
timer.Enabled = True
timer.Interval = 500
AddHandler timer.Tick, AddressOf clockUpdate
End Sub
Sub clockUpdate(ByV al sender As Object, ByVal e As System.EventArg s)
Dim valLocalTime As System.Windows. Forms.Label = Nothing
Dim frm As System.Windows. Forms.Form =
System.Windows. Forms.Form.Acti veForm
Try
valLocalTime = frm.Controls.Fi nd("valLocalTim e", True)(0)
Catch ex As Exception
End Try
If Not valLocalTime Is Nothing Then valLocalTime.Te xt =
My.Computer.Clo ck.LocalTime.To String("HH:mm:s s") & " EDT"
valLocalTime = Nothing
frm = Nothing
End Sub
Comment