Jul 25, 2008

Using A Timer In A Array...

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > VB Programming

free web hosting

Using A Timer In A Array...

kvarnerexpress
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 Explict
Dim WithEvents tmrTimer1 As VB.Timer

Private 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...

Reply

whyme
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.


CODE
Option Explicit

Private Sub Form_Load()
Timer1.Interval = 1000
Label1.Caption = "601"
End Sub

Private Sub Timer1_Timer()
If Label1.Caption = 0 Then
Timer1.Enabled = False
MsgBox "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 = 1000
Label1.Caption = "601"
Timer1.Enabled = True
Label1.Refresh
Else
Label1.Caption = Label1.Caption - 1
End If

End 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.

Reply

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

For i=1 to 10
 Load Timer(i)
 Timer(i).interval = 100
 Timer(i).enabled = true
Next i

And you would have something like this
CODE

Private Sub Timer(Index As Integer)
Select Case Index
Case 0
' code to execute for Timer(0)
Case 1
' code to execute for Timer(1)
Case Else
' other code
End Sub

I wrote it from the head, didn't try it, but I think it should work...

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. arrays de timer - 60.22 hr back. (1)
  2. array of timers - 95.04 hr back. (1)
  3. timer array vb6 - 109.50 hr back. (1)
Similar Topics

Keywords : timer array

  1. Timer - is it possible in vb 6.0 to make a while statement which executes ever (6)
  2. Timer Control Key Press Every Minute Vb2005 - (0)
    hi you all, I am totally new, and i tried it for days now in VB2005 (free one /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />). Like the topic already
    said i want to make a program that press a keybord key every minute for a program that is running on
    the background (small window, half the size of the total screen). I also searched alot on the web,
    and finally found this one: http://www.trap17.com/index.php/creating-t...ram_t35341.html I hope
    you guys could refine it a bit to the thing I mentioned above because i cant figure ...



Looking for timer, array

Searching Video's for timer, array
advertisement



Using A Timer In A Array...



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE