I'm trying to get a picture box to load a new picture every second with a timer.

Heres my code.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
     
Do While Timer1.Enabled = True

            frame = frame + 1


            frame1 = 'Picture Location
            frame2 = 'Picture Location
            frame3 = 'Picture Location
            frame = 0


            Select Case frame
                Case 1
                    Player.Image = Image.FromFile(frame1)
                Case 2
                    Player.Image = Image.FromFile(frame2)
                Case 3
                    Player.Image = Image.FromFile(frame3)
                Case Is > 3
                    frame = 0
            End Select
        Loop
    End Sub

What am i doing wrong that the program keeps crashing and the sequence doesn't work.

mate I may be able to help you but i need vb 2003 software which i am unable to install through internet.If you can upload your setup on ay upload site or mail me the web add, then I can help.
ankitdbst@gmail.com

Store the path of file into an array or arraylist.

Dim Ar(2) as String
      Dim I as Integer
    Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form1.Load
       Ar(0)="file1.gif"
       Ar(1)="file2.gif"
       Ar(2)="file3.gif"
       I=0
   End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    if I>=Ar.Length then
        I=0
    End If
    Player.Image = Image.FromFile(Ar(I))
    End Sub

thanks adatapost you were correct about the timer sub code (except you forgot I = I + 1) and i always forget to use arrays to clean up my variables thanks for your help.

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