Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Using A Timer In A Array...

Recommended Posts

I'm usually very well a creating a problems and then finding a solution. However this time I'm stumped.I'm attempting to create timers.. I know this is possible by doing... visual basic code:--------------------------------------------------------------------------------Option ExplictDim WithEvents tmrTimer1 As VB.TimerPrivate Sub Form1_OnLoad()Set tmrTimer1 = Me.Controls.Add("VB.Timer", "Timer1")End Sub--------------------------------------------------------------------------------Now, what I need is to be able to create those timers, but creating them so they belong to an array of timers.Any ideas, hints, suggestions...???__________________' Comments go here...

Share this post


Link to post
Share on other sites

Heh heh, You've come to the right guy. I've madea little 10 mintue timer scirpt with VB, and after 10 mins, it auto resets it self. Here's the code.


Option ExplicitPrivate Sub Form_Load()Timer1.Interval = 1000Label1.Caption = "601"End SubPrivate Sub Timer1_Timer()If Label1.Caption = 0 ThenTimer1.Enabled = FalseMsgBox "10 minutes is up! - REMEMBER THE 10-10-10 RULE." & Chr$(10) & "Look at something 10 feet away for 10 seconds." & Chr$(10) & "Click OK to restart the timer."Timer1.Interval = 1000Label1.Caption = "601"Timer1.Enabled = TrueLabel1.RefreshElseLabel1.Caption = Label1.Caption - 1End IfEnd Sub

I'm not sure about the arrays, but here is how it should work. You need to drop in a label, and a timer function for it to work.

Share this post


Link to post
Share on other sites

Just drop a Timer on a form, and set it's index to 0... then Load new timers, like this

For i=1 to 10  Load Timer(i)  Timer(i).interval = 100  Timer(i).enabled = trueNext i
And you would have something like this
Private Sub Timer(Index As Integer)Select Case IndexCase 0' code to execute for Timer(0)Case 1' code to execute for Timer(1)Case Else' other codeEnd Sub
I wrote it from the head, didn't try it, but I think it should work...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.