473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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.IndexOutOfRangeException' 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(ByVal timer As System.Windows.Forms.Timer)
timer.Enabled = True
timer.Interval = 500
AddHandler timer.Tick, AddressOf clockUpdate
End Sub

Sub clockUpdate(ByVal sender As Object, ByVal e As System.EventArgs)
Dim valLocalTime As System.Windows.Forms.Label = Nothing
Dim frm As System.Windows.Forms.Form =
System.Windows.Forms.Form.ActiveForm

Try
valLocalTime = frm.Controls.Find("valLocalTime", True)(0)
Catch ex As Exception

End Try

If Not valLocalTime Is Nothing Then valLocalTime.Text =
My.Computer.Clock.LocalTime.ToString("HH:mm:ss") & " EDT"
valLocalTime = Nothing
frm = Nothing
End Sub

Jun 18 '07 #1
1 1319
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. ;)

Jun 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: William Bub | last post by:
Is there an accurate way to create a "stopwatch" good to 1/10 of a second? I'm not sure if I should use the timer control, or some way to access the computer timer. I found the following site...
3
by: David | last post by:
Hi There! I'm using Timer control to record how long my application perform certain tasks. However, apparently Timer control is not doing its' job (i.e. Not firing Tick event) while my...
2
by: Rajesh Abraham | last post by:
I have a timer in my Windows Service project and I am trying to do some processing on the tick event of the timer but this event does not seesms to be raised. Below is some code segment. Any Idea?...
3
by: | last post by:
Hi,all I want to change Control's size&location in runtime ,(C#) but i dont know how to do! :(so, can you provide me with document about this. my email: zhonghua@rinpak.com.cn ...
5
by: robert | last post by:
Turning algs for old NumPy modules into numpy code I suffer from this: Upon further processing of returns of numpy calculations, lots of data in an apps object tree will become elementary numpy...
1
by: mpbejo | last post by:
I have an application developed with VisualBasic 2005 that use .Net Framework 2.0. This application works 24 Hours day, 7 days at week. It works fine but sometimes (every two/three days) the...
3
by: Joseph Gruber | last post by:
Hi all -- I have two questions. First, I'm adding a control to my form at runtime and the control/form seems to ignore the anchor property of the runtime control. Any idea how I can get a...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.