Clear or Remove the PictureBox from images - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This is a tutorial on how to clear the image from the picture box control in visual basic .net

clear an image in visual basic .net

Clear Button Code

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        PictureBox1.Image = Nothing
End Sub

After you remove the image from the picturebox you can also call the dispose method to release the resource in the picturebox

It is nessecary to dispose the picture

Releasing the resources after you remove an image allows you to edit, rename, or delete the image from a different program without any affect from your visual basic application.

Before you call the dispose method, make sure that the picturebox doesn't have an image, otherwise you will get an error exception. This is what the following code does:

 If PictureBox1.Image Is Nothing Then
 End If

Share This

Home | About | Contact | Privacy Policy

Copyright 2017 - All Rights Reserved.