How to Make a Gallery of Images in Visual Basic 6.0

Written by laura gittins
  • Share
  • Tweet
  • Share
  • Email

You can use Visual Basic to create a program to display a group of images any way you wish, such as in slideshow or thumbnail format. VB 6.0 has ImageList control, which stores images in an array that you can access with the index and display in one or more Image controls.

Skill level:


  1. 1

    Click "Project" on the menu and then click "Components" from the drop down list, or press "CTRL+T" on the keyboard to open the Components menu. Scroll down to "Microsoft Windows Common Controls 6.0 (SP6)" and click the check box beside it. Click "OK." This adds several new tools to the toolbox, including the ImageList control.

  2. 2

    Double-click the ImageList control in the toolbox to add one to your form. Click on the ImageList on your form and double-click the "(Custom)" option from the Properties window. This opens up a dialogue box for your images.

  3. 3

    Click on the "Images" tab. Click on "Insert Picture" and navigate to your pictures. Double click on the one you need to load it into your ImageList. Repeat this process to upload all of the pictures you need. Click "OK" to close the box.

  4. 4

    Double-click the "Image" control in the toolbox to add one to your project. Click and drag its edges to resize it if necessary. Change the "Stretch" property to "True."

  5. 5

    Add two CommandButton controls from the toolbox to your form. Change the "Caption" property of the first to "Previous" and of the second to "Next." Arrange your controls on your form. Your ImageList control will not show at run time, so you can leave it wherever you prefer.

  6. 6

    Open the code window. Create a global count variable by typing "Dim picNum As Integer" under "Option Explicit." Access your "Form_Load()" function. Type "picNum = 1" on the first line and "Image1.Picture = ImageList1.ListImages.Item(picNum).Picture" on the next line. This will load the first image in your ImageList into your Image box.

  7. 7

    Open the code for your "Next" command button and type the following lines:

    If Not picNum = ImageList1.ListImages.Count Then

    picNum = picNum + 1


    picNum = 1

    End If

    Image1.Picture = ImageList1.ListImages.Item(picNum).Picture

  8. 8

    Open the code for your "Previous" command button and type the following lines:

    If Not picNum = 1 Then

    picNum = picNum - 1


    picNum = ImageList1.ListImages.Count

    End If

    Image1.Picture = ImageList1.ListImages.Item(picNum).Picture

  9. 9

    Run your program and test your buttons. The image control will display an image from your ImageList. Cycle through the images by clicking the Previous and Next command buttons.

Tips and warnings

  • You do not need to use command buttons to control how your program displays images. You can use multiple Image controls to display multiple images at once, or you can use a timer that will automatically change the displayed image in your Image control whenever the timer interval elapses.

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.