?
Solved

Visual Basic 6

Posted on 2003-02-18
3
Medium Priority
?
158 Views
Last Modified: 2010-04-17
I want to use a timer control to step through 4 images.
Example:
Image one becomes visible after xx time then
Image two becomes visible after xx time
and so on until all 4 images are visible.

How do I do this under the timer control?

Thanks.

0
Comment
Question by:kccpo
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
jimcpl earned 150 total points
ID: 7979505
Hi kccpo,

What's below assumes that you have 4 Pictureboxes (Picture1, Picture2, Picture3, and Picture4) on your form, and one image assigned to each Picturebox.

1) Click on Timer icon in VB toolbar on left, then click drag a timer control onto your form.  This'll be "Timer1".

2) In "General" "Declarations", add a variable:

Private Pict_Index as Integer

3) In your Form_Load, add:

PictIndex = 0
Picture1.Visible = False   'picture is initially invisible
Picture2.Visible = False   'picture is initially invisible
Picture3.Visible = False   'picture is initially invisible
Picture4.Visible = False   'picture is initially invisible
Timer1.Interval = xxx      ' xxx is in milliseconds
Timer1.Enabled = True

4) Double-click on the timer icon on your form.  This will open up a code window for Private Sub Timer1_Timer().

5) In Timer1_Timer, add the following code:

Select Case Pict_Index

Case 0
   Pict_Index = Pict_Index + 1
   Picture1.Visible = True

Case 1
   Pict_Index = Pict_Index + 1
   Picture2.Visible = True

Case 2
   Pict_Index = Pict_Index + 1
   Picture3.Visible = True

Case 3
   Pict_Index = Pict_Index + 1
   Picture4.Visible = True

End Select

That should do it!

Jim
0
 
LVL 4

Expert Comment

by:Sashi Rachabattula
ID: 7979741
here is sample code
in form u have to add a picture box and a timer

Dim pic1 As String
Dim pic2 As String
Dim arraynumber As Integer
Dim myarray(10) As String
Dim flag As Integer


Private Sub Form_Load()
Timer1.Interval = 1000
myarray(0) = "c:\img1.jpg"
myarray(1) = "c:\img2.jpg"
myarray(2) = "c:\img3.jpg"
myarray(3) = "c:\img3.jpg"


arraynumber = 4
flag = 0
End Sub

Private Sub Timer1_Timer()
If flag > arraynumber Then
flag = 0
End If
Picture1.Picture = LoadPicture(myarray(flag))
flag = flag + 1

End Sub
0
 
LVL 4

Expert Comment

by:Sashi Rachabattula
ID: 7979742
change..

If flag > arraynumber Then
flag = 0
End If

as..

If flag = arraynumber Then
flag = 0
End If

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Progress
Starting up a Project

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question