Visual Basic Code of the Week (COTW)
Issue #120
Online Version at (paid subscribers only)
All content and source code is Copyright (c) 2000 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Issue topic: Creating thumbnail images using native controls

Earn REAL money surfing the web!

If you would like to make some extra cash for surfing the web, jump to


In this Issue

In this issue we discuss how to take any image and create a thumbnail version of it.

If you have any questions about using this module, let us know at


This module contains a single routine called CreateThumbnail that takes an image and creates a new version of the image in bitmap format that can be used as a thumbnail version of the original graphic. This is useful for any application that needs to show many large images in a smaller space (such as an image viewing program). It can also be useful for generating thumbnail graphics for use on the web (i.e. catalog images, product images, etc)

We are planning on expanding this module to include routines to aid in the creation of a full-blown image viewer. With the proliferation of digital cameras and online images we have been receiving many requests for routines to help manage these graphics. If you have any suggestions, drop us an email at


Public Sub CreateThumbnail(Picbox As PictureBox, sImageFile As String, sThumbnailFile As String)

This routine requires the existence of a PictureBox on a form. It does not have to be a visible PictureBox. picbox is the PictureBox on your form. sImageFile is the name of the image file to load into picbox for which you want to create a thumbnail graphic. sThumbnailFile is the file that the thumbnail graphic will be saved into. It should have an extension of BMP since the SavePicture method that this routine uses only supports the saving of bitmaps.

It will not change the original graphic in any way.

Any errors which occur in this routine (such as a missing file) will be raised to the caller.

Sample Usage

This example will take the image file called e:\pics\p1010023.jpg and convert it to a thumbnail called e:\pics\thumb-p1010023.bmp.

    CreateThumbnail pic, "e:\pics\p1010023.jpg", "e:\pics\thumb-p1010023.bmp"

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address:

This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Get paid to surf the web!

If you would like to get paid for surfing the web, jump to

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945