?
Solved

how to display images with delay

Posted on 2003-11-25
6
Medium Priority
?
341 Views
Last Modified: 2012-05-04
the current problem that i'm facing now is, i want to display one image after another with a delay in between but i'm only seeing the last image.
please help.
thanks
0
Comment
Question by:leeh0003
[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
6 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 9823039
Use the Pause() sub shown below to implement the delays you want. You can use the Sleep() API function also but it will cause the entire thread to "sleep" which you probably won't want to happen.


Form1:

Option Explicit
Public Sub Pause(ByVal Interval As Integer)
    Dim Current As Integer
    Current = Timer
    Do While Timer - Current < Val(Interval)
        DoEvents
    Loop
End Sub
Private Sub Form_Load()
    MsgBox "Test 1"
    Call Pause(3) 'Pause 3 seconds
    MsgBox "Test 2"
End Sub
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9823055
Try using timer.
--------------------------------------------------------------------------------------------------------------
Dim image(4) As String                                  'Create a string array which will store paths
Dim counter As Integer                                  'Counter used by Timer

Private Sub Form_Load()
    image(0) = "c:\test\pic1.bmp"                       'Set paths to your images
    image(1) = "c:\test\pic2.bmp"
    image(2) = "c:\test\pic3.bmp"
    image(3) = "c:\test\pic4.bmp"
    counter = 0
    Timer1.Interval = 200                               'Set interval between two differrent images (miliseconds)
End Sub

Private Sub Timer1_Timer()
    counter = counter + 1
    If counter > UBound(image) Then counter = 0         'If counter exceeds the last picture index then set it back to 0
    Picture1.picture = loadimage(image(counter))        'Display the picture
    Picture1.Refresh
End Sub
--------------------------------------------------------------
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9823064
If you don't want images to show in loop then use       >>    If counter > UBound(image) Then Timer1.Enabled = False      <<     instead of               If counter > UBound(image) Then counter = 0
0
Independent Software Vendors: 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!

 

Author Comment

by:leeh0003
ID: 9823069
What does your variable Timer means?  Is it sometihing that we initialised or it's n internal function? Please advise.
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 9823177
Timer is a control in Visual Basic (Little stop watch icon in tool bar), which can be used to run one code several times using interval.

In order to see how it works. Create new standard exe project.
Drag Command button and timer control to a form.

Click on newly created Timer1 control and set its interval property to 500 (miliseconds)

Paste this code:    When you click on command button, background color should start blinking.
---------------------------------------------------------------
Private Sub Command1_Click()
    Timer1.Enabled = True                   'Start the timer
End Sub

Private Sub Form_Load()
    Timer1.Enabled = False                  'Ensure that timer is disabled after loading a form
End Sub

Private Sub Timer1_Timer()                      'This is the code that timer executes every time
    If Form1.BackColor = vbButtonFace Then              'routine for changing colors
        Form1.BackColor = vbHighlight
    Else
        Form1.BackColor = vbButtonFace
    End If
End Sub
----------------------------------------------
0
 
LVL 1

Accepted Solution

by:
CycLonE earned 375 total points
ID: 9824369
I have a very easy solution, try it ;-)

add an ImageList to your project, add the images to the imagelist...

then using a timer: specify the interval you want...
and cycle through the images by using a variable and incrementing the variable each time the timer is triggered... using this variable as the imagelist index select the pictures...

0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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