Look at this code, it's so simple, yet I can't manage to get it to work!! PLEASE HELP ME, I'VE BEEN TRYING TO GET IT TO WORK FOR HOURS!!!!
on the top of form1 is
Code:
Option Strict On
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Code:
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim TempBmp As Bitmap = New Bitmap(PictureBox1.Image.Size.Width, PictureBox1.Image.Size.Height)
Dim MyColor As Color
TempBmp = System.Drawing.Bitmap.FromHbitmap(PictureBox1.Handle)
MyColor = (TempBmp.GetPixel(1, 1))
Label4.Text = MyColor.ToString
end sub
And the error happens at this line
Code:
Dim TempBmp As Bitmap = New Bitmap(PictureBox1.Image.Size.Width, PictureBox1.Image.Size.Height)
The error message that I get is
Code:
NullReferenceException was unhandled
Object reference not set to an instance of an object.
That's everything and there is a picture loaded (partial screenshot of desktop) yet it does not work. How could this be?