Runtime Control & Timer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joseph  Gruber

    #1

    Runtime Control & Timer

    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

  • Joseph  Gruber

    #2
    Re: Runtime Control & Timer

    Never mind -- it looks when I switched between my application's form
    and the VS.Net debug console the "ActiveForm " was actually changing to
    the VS.Net debug console. ;)

    Comment

    Working...