Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB timer problem

Status
Not open for further replies.

grierfield

Technical User
Dec 18, 2002
55
0
0
US
How do I write a VB procedure that will display say 3 picture with equal delays if I set the timer1.interval = 500.

So after .5 seconds the first picture becomes visible – then after another .5 seconds the other picture becomes visible … and so on.

thanks
 
I would assume you can assign a variable to part of the image name as an integer, and then loop them. say for example you have 3 pictures, then name them:

pic1
pic2
pic3

then maybe write something like this with the on timer event:
Code:
dim i as integer
timerinterval = 500
i = 1

  controls("pic" & cstr(i)).visible = true
 
Private Sub tmrFaces1_Timer()

Static counter
Select Case counter
Case 0
imgFace(0).Visible = True
Case 1
imgFace(1).Visible = True
Case 2
imgFace(2).Visible = True
Case 3
imgFace(3).Visible = True
End Select
counter = counter + 1
If counter > 4 Then
counter = 0

End If

End Sub
The above procedure works – now I am trying to reverse the procedure – to turn off the visibility of each picture going from last to first but that’s not working properly
 
What about this (typed, untested) ?
Code:
Private Sub tmrFaces1_Timer()
Static counter As Integer, f As Boolean
If Not f Then
    imgFace(counter).Visible = True
Else
    imgFace(3 - counter).Visible = False
End If
If counter >= 3 Then
    counter = 0
    f = Not f
Else
    counter = counter + 1
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That almost worksed – I removed the 4th then the third and then the second -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top