?
Solved

Visual Basic 6

Posted on 2003-02-18
3
Medium Priority
?
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 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