Need Visual Studio help

Ok. So what I want to do is move a picture box I have over 5 pixels for each arrow press. For example, if I press the right arrow, I want the image to move 5 spaces right. I also need it to do arc jumps, so I can jump over obstacles, and I need it to detect the color of pixels some how, so if it hits a green one (ground), it won't be able to go any lower. And if it hits a certain shade of grey (end of map), it will go to the next level. I have VS 2005 pro. I've tried keys.up, but I can't get anything working like that, and the only thing that can seem to have answers is "Experts Exchange".
 
Ok so I can get the picturebox to move now, and I have a thing that I got from my teacher that shows how to have it know when it's over a certain pixel. His example works fine, but even if I copy the code and make identical objects, it doesn't work. Here's the code.

Public Class Form1
Dim col As Integer = 45
Dim row As Integer = 39

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

Select Case e.KeyCode
Case Keys.Right
If CType(PictureBox1.Image, System.Drawing.Bitmap).GetPixel(PictureBox2.Right + 1, PictureBox2.Top).ToArgb() = Color.Black.ToArgb() Then
Label1.Text = "Black"
Else
Label1.Text = "White"
End If
col = col + 1
PictureBox2.Location = New Point(col, row)
e.Handled = True

Case Keys.Left
If CType(PictureBox1.Image, System.Drawing.Bitmap).GetPixel(PictureBox2.Left - 1, PictureBox2.Top).ToArgb() = Color.Black.ToArgb() Then
Label1.Text = "Black"
Else
Label1.Text = "White"
End If

col = col - 1
PictureBox2.Location = New Point(col, row)
e.Handled = True

Case Keys.Up
If CType(PictureBox1.Image, System.Drawing.Bitmap).GetPixel(PictureBox2.Top - 1, PictureBox2.Top).ToArgb() = Color.Black.ToArgb() Then
Label1.Text = "Black"
Else
Label1.Text = "White"
End If

row = row - 1
PictureBox2.Location = New Point(col, row)
e.Handled = True

Case Keys.Down
If CType(PictureBox1.Image, System.Drawing.Bitmap).GetPixel(PictureBox2.Bottom + 1, PictureBox2.Top).ToArgb() = Color.Black.ToArgb() Then
Label1.Text = "Black"
Else
Label1.Text = "White"
End If

row = row + 1
PictureBox2.Location = New Point(col, row)
e.Handled = True


End Select
End Sub

End Class

I get this error
A first chance exception of type 'System.NullReferenceException' occurred in 2.exe
 
Back
Top