473,399 Members | 3,302 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,399 software developers and data experts.

Dynamically add timer

Is there any way to add a timer control while run time

similar to textbox
Set txtNew = Controls.Add("VB.TextBox", "TextDynamic")
Feb 29 '08 #1
3 2826
Killer42
8,435 Expert 8TB
Is there any way to add a timer control ...
You might be able to work without it. If you need to do multiple timers, why not just use a single control and fire different events based on your own counters? For example...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Timer()
  2.   Static Counter1 As Long
  3.   Static Counter2 As Long
  4.   Counter1 = Counter1 + 1
  5.   Counter2 = Counter2 + 1
  6.   If Counter1 >= Limit1 Then
  7.     ' Call your first timed routine
  8.     Counter1 = 0
  9.   End If
  10.   If Counter2 >= Limit2 Then
  11.     ' Call your second timed routine
  12.     Counter2 = 0
  13.   End If
  14. End Sub
  15.  
Of course, it would be better to base the events on actual elapsed time since the last firing, rather than a simple count, in case you need to change the Interval of the timer control.
Mar 3 '08 #2
QVeen72
1,445 Expert 1GB
Hi,

Place a Timer On the Form in Design Time, and Make Index = 0
To Add One More Timer, just use this code:

Load Timer1(1)

With above code, you can use Events associated with cotrols loaded during Run-Time...
But if you add Controls, You have to Create Events, Which is a Very Tedious process..


Regards
Veena
Mar 3 '08 #3
Killer42
8,435 Expert 8TB
Yes, if you're using VB6, then a control array is certain to be the simplest way to implement this.
Mar 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
1
by: CES | last post by:
All, I have absolutely no clue as to what the difference is between these two snippets but the on that is hard coded works and the other doesn't. I know it's something incredible stupid that I...
8
by: CES | last post by:
All, I'm sorry but I still don't get this!! I'm trying to use a variable that is passed into a function to to dynamically name an instance of an Object(). I've created a Timer() Object that seems...
3
by: GoneRural | last post by:
Hello, I am trying to figure out how to create multiple timers at run-time (which could vary each time) that I can then reference? Basically I have a service that will check a registry key and...
6
by: Aspiring .NET Programmer | last post by:
Happy Friday everyone!!! I am working on a windows service and a C# application and needed some help with certain functionality. Please read through my issue below. Thanks! I have a windows...
9
by: paul | last post by:
Hi All, We have a small dilemma. We have the following page: http://giggsey.com/m00Cow.php (don't ask about the content) that we want to turn into an interactive application for some new intake...
0
by: fredd00 | last post by:
Hi, I'm running 4 update panel on a page, only one showing at a time (using css ) the panels are all being updated on a timer tick ( 1 timer 4 updates) they all query rss url to update their...
15
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.