How to Save Images From the PictureBox Control in Visual Basic

Written by kevin walker
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Save Images From the PictureBox Control in Visual Basic
The PictureBox control can show images in your Visual Basic program. (a lot pf pictures - flowers. image by Olaru Radian-Alexandru from

The PictureBox component in Visual Basic is used to display images in your Visual Basic program, making it useful for programs like image browsers and previewers. There is no command directly built into the PictureBox component to save images, but a few other classes that come with Visual Basic can help you out.

Skill level:

Other People Are Reading

Things you need

  • Visual Basic 2008 or later

Show MoreHide


  1. 1

    Drag the "PictureBox" component onto your form from the component list on the left side of the screen.

  2. 2

    Drag the "Button" component onto your form from the component list. Drop it so that it is next to or under the PictureBox component.

  3. 3

    Go to the "Properties" window in the bottom right of the screen and change the text property so it reads "Save."

  4. 4

    Double-click the button you just added. This will create an event function for when the user clicks the button and automatically take you to the new function in the program editor. It will be named something similar to "Private Sub Button1_Click."

  5. 5

    Paste the following code into the function:

    Dim image As Image = PictureBox1.Image

    This fetches the image data from the PictureBox and places it in an "Image" object. Though this object is invisible to the user, it contains a function, "Save," which will be very useful.

  6. 6

    Paste the following line of code directly under the last one:

    image.Save("C:\image.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

    This saves the image to the file "C:\image.jpg" using the JPEG image format from the System.Drawing.Imaging.ImageFormat class.

    Other supported image formats in the ImageFormat class include BMP, EMF, EXIF, GIF, GUID, ICON, JPEG, MemoryBmp, PNG, TIFF and WMF. They are referenced the same way as the JPEG image format. For example, if you want to save a PNG file, you would replace the image.Save command above with this one:

    image.Save("C:\image.png", System.Drawing.Imaging.ImageFormat.Png)

Tips and warnings

  • Nothing in the image.Save command prevents you from assigning an image file the wrong file extension. For example, the following command will not generate an error:
  • image.Save("C:\image.bmp", System.Drawing.Imaging.ImageFormat.Jpeg)
  • Your program will proceed to save a JPEG file with a BMP file extension. This may confuse some users and image viewing applications and may cause compatibility problems for your images.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.