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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

timers

Status
Not open for further replies.

DUF

Technical User
Mar 10, 2001
107
IE
Hi, I am Learning vb at a night course and need help with a timer project.
I want to display an image on the form for five different states.
Using Select case statements
As in
Case 0 image visible for 3 seconds
Case 1 image not visible for 1 second
Case 2 image visible for 1 second
Case 3 image not visible for 1 second
Case 4 image visible for 1 second
Case 5 image not visible for 3 second

This is the code I tried but did not work
Any ideas would help

Thanks
Duf

Dim picture as integer

Private Sub Form_Load()
Picture = 0
End sub

Private Sub tmrImage_Timer()
For picture = 0 to 6 -1
Select case picture
Case is = 0
Static counter0
If (counter < 3) then
Image.visable = true
End if
Counter0 = counter0 + 1
Case is = 1
Static counter1
If (counter1 < 1) then
Image.visable = False
End if
Counter1 = counter1 + 1
Case is = 2
Static counter2
If (counter2 < 1) then
Image.visable = True
End if
Counter2 = counter2 + 1
Case is = 3
Static counter3
static counter3
if (counter3 < 1) then
image.visable = false
end if
counter3 = counter3 + 1
case is = 4
static counter4
if (counter < 1 ) then
image.visable = true
end if
counter4 = counter4 + 1
case is = 5
static counter5
if (counter < 3 ) then
image.visable = false
end if
counter5 = counter5 + 1
end select

next picture





End sub
 
Well, this might help....
First of all &quot;visible&quot; is misspelled in all the Case statements. I can't figure out what &quot;counter&quot; and &quot;static counter&quot; are used for, but you need these following 2 properties to manipulate the control:
tmrName.Enabled = True (or false)
tmrName.Interval = 2000 (this is 2000 ms, or 2 seconds)
Hope this is what you needed!
 
Okay,
Well to add to genomon. You've kinda got off Track heres what you need in additon t o the timer.

Dim Counter as Interger

Private sub timer1_Timer()
Counter = Counter+1

if counter=6 then
counter = 0
end if

select case counter
case 0
Image1.picture = loadpicture(&quot;c:\somepic1.gif&quot;
case 01
Image1.picture = loadpicture(&quot;c:\somepic2.gif&quot;
case 02
Image1.picture = loadpicture(&quot;c:\somepic3.gif&quot;
case 03
Image1.picture = loadpicture(&quot;c:\somepic4.gif&quot;
case 04
Image1.picture = loadpicture(&quot;c:\somepic5.gif&quot;
case 05
Image1.picture = loadpicture(&quot;c:\somepic6.gif&quot;
end select
end sub

That should help.. Brad,
Hey! email me any time! Bradsvb@yahoo.com
 
Don't forget to add the &quot;Timer&quot; reference to your form and set the interval to &quot;1&quot;, but of course you knew this right!

s-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top