Hi, I have a small program that displays a number of pictures by using a timer. I don't know if this is the best way to do this, but it works. What I would like to do is add a cmdButton so that every time I hit the cmdSwing button the Timer1_Timer runs displaying the pictures again.
Here's my code (don't laugh). How can I get the cmdSwing to actually initiate the timer section?

Dim inc As Integer
Dim objPics(7) As String

Private Sub cmdSwing_Click()
    Timer1.Interval = 50
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
'Dim objPics(7) As String
    ' Load bitmaps int the Picture object array.
    objPics(0) = "C:\Holding\VBstuff\VBA_Lesson_Programs\pic1.bmp"
    objPics(1) = "C:\Holding\VBstuff\VBA_Lesson_Programs\pic2.bmp"
    objPics(2) = "C:\Holding\VBstuff\VBA_Lesson_Programs\pic3.bmp"
    objPics(3) = "C:\Holding\VBstuff\VBA_Lesson_Programs\pic4.bmp"
    objPics(4) = "C:\Holding\VBstuff\VBA_Lesson_Programs\pic5.bmp"
    objPics(5) = "C:\Holding\VBstuff\VBA_Lesson_Programs\pic6.bmp"
    objPics(6) = "C:\Holding\VBstuff\VBA_Lesson_Programs\pic7.bmp"
    If inc < 7 Then
        pic = objPics(inc)
        Picture1.Picture = LoadPicture(pic)
        inc = inc + 1
    Else
        Timer1.Enabled = False
    End If
End Sub

if u wish to call the cmdswing_click event from another event just call it under it. like if u want to call it in form_load event the syntax will be :-

private sub form_load()
call cmdswing_click
end sub

or if u wish to call the same event from an outside procedure declare the cmdswing_click event as public like this :-

public cmdswing_click()
<your code goes here>
end sub

now u can call the event from another form just like this :-
private sub form_load() 'this is form2
call form1.cmdswing_click
end sub

hope this will help
regards
Shouvik

Hello and thanks, but waht I was looking for is a way to initiate the picture sequence every time I hit the "Swing" cmdbutton. When I launch the program, the pictures automatically run. What I would like to do is pick the "Swing" cmdbutton and watch the pictures run again, every time I hit the button.

Hey thank you very much! That worked great.

Have a great day.
Mark

This question has already been answered. Start a new discussion instead.