Search code examples
vb.netpicturebox

Check if PictureBox is empty


I have a simple program where the user needs to input an image and other info, e.g. Lname, Fname, etc. Then I need the data that will be saved really contains the Image in the PictureBox.

I have tried this in an If statement:

picturebox1.image = nothing

but of course it wont work. I don't know the codes to prevent the user save the data without the Image

If tbLName.Text = "" Or
   tbFName.Text = "" Or
   picturebox1.image = Nothing or
   cbCategory.SelectedIndex = -1 Then
    MessageBox.Show("Input data to Update", "Update", 
    MessageBoxButtons.OK, MessageBoxIcon.Error)
    Return            
End If

Solution

  • Try

    picturebox1.image Is Nothing