|
-
Aug 4th, 2000, 04:25 PM
#1
Thread Starter
Junior Member
Must be simple but how do I loop through the listbox and set several intervals for the same timercontrol. Here is my source:
Private Sub Command1_Click()
Timer1.Interval = List1.List(0)
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
List1.AddItem 1000
List1.AddItem 2000
List1.AddItem 3000
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
MsgBox List1.List(0)
timer1.interval = false
End Sub
The result I want to have is that after 1 second a message appears, after 2 seconds the next message appears, etc...
-
Aug 4th, 2000, 04:42 PM
#2
Hyperactive Member
Try this:
[code]
Dim x
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
x = 0
List1.AddItem 1000
List1.AddItem 2000
List1.AddItem 3000
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
MsgBox List1.List(x)
x = x + 1
Timer1.Interval = x * 1000
End Sub
[\code]
It should work for you. The x*1000 means that it will be an x second interval.
bob
-
Aug 4th, 2000, 05:05 PM
#3
_______
<?>
Hansz:
Close, you forgot to loop so x never grows
Code:
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
x = 0
List1.AddItem 1000
List1.AddItem 2000
List1.AddItem 3000
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Do
MsgBox List1.List(x)
x = x + 1
Timer1.Interval = x * 1000
Loop Until x = 3
Timer1.Enabled = False
End Sub
[Edited by HeSaidJoe on 08-04-2000 at 06:07 PM]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 5th, 2000, 12:49 AM
#4
Hyperactive Member
eek NO!
don't do what he said. That doesn't do what you want. His will give you a bunch of messageboxes at once, and that's bad. He does have a point on the x growing business. Change that sub to the following:
Code:
Private Sub Timer1_Timer()
If x <= List1.ListCount Then
MsgBox List1.List(x)
x = x + 1
Timer1.Interval = x * 1000
Else
Timer1.Enabled = False
x = 0
End If
End Sub
that will loop until the end of the list, making the timer interval increase by a second each time, and displaying the message box after each interval.
bob
-
Aug 5th, 2000, 09:52 AM
#5
_______
<?>
BULL..
it will give you the message boxes 1 sec apart as the question asked for (and yes that, in my opinion is more than one would want). If you want more time between messages you increase the interval.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 5th, 2000, 11:03 AM
#6
Thread Starter
Junior Member
thanx all but forgot something???
thanx all but I don't want the value of x set to be the timer interval? The timer interval must be set by the values in the listbox.
What will happen if I change these values??????
-
Aug 5th, 2000, 11:37 AM
#7
Thread Starter
Junior Member
Thanx Bob, think I have it allready
In the source below I can use different and more or less values in the listbox, now it's complete:
Private Sub Timer1_Timer()
If x <= List1.ListCount - 1 Then
Timer1.Interval = List1.List(x)
MsgBox List1.List(x)
x = x + 1
Else
Timer1.Enabled = False
x = 0
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|