Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I'm having a picturebox which I need to animate, i.e. to move and change the image.

VB
Imports System
Imports System.Drawing
Public Class Form1

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Static x As Integer = 5
        Static y As Integer = 0
        Static flip As Integer = False
        If y Mod 2 = 0 Then
            Me.PictureBox1.Image = My.Resources.Resource1.Bird_l
        Else
            Me.PictureBox1.Image = My.Resources.Resource1.bird_r
        End If
        If Me.PictureBox1.Left >= 500 Then
            x = -5
            flip = True
        ElseIf Me.PictureBox1.Left <= 0 Then
            x = 5
            flip = False
        End If
        If flip = True Then
            Me.PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)
        End If
        Me.PictureBox1.Left = Me.PictureBox1.Left + x
        y += 1
    End Sub
End Class


While running it's showing error in the line:-

VB
Me.PictureBox1.Image = My.Resources.Resource1.bird_r
- "Parameter Not Valid"

Why is the error?

Thanx
Posted
Updated 6-Oct-11 23:19pm
v3

1 solution

You need to check how you have added the resources My.Resources.Resource1.Bird_l and My.Resources.Resource1.Bird_r as the code works for me after testing it with my own images. Does intellisense give any indication that the declaration of these resources is wrong? When I add an image to a resource file I use My.Resources.myImageName.
 
Share this answer
 
Comments
DEB4u 7-Oct-11 5:28am    
Ya the images are added to the resource file. It's showing a runtime error.
Wayne Gaylard 7-Oct-11 5:34am    
Well you code works fine, so I would investigate whether the image resources are correct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900