How to Create a New VB PictureBox

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Create a New VB PictureBox
Load images to a VB program. (Creatas/Creatas/Getty Images)

If you're tired of using third-party photo albums and you want to create your own, then dynamically creating picture boxes in your VB application is the way to go. In VB or Visual Basic, you can use the "PictureBox" constructor to initialise a new instance of the "PictureBox" class. Make your application dynamic by not having to predefine the amount of pictures the user can load. Give users the option to choose their images and create only the amount of picture controls needed.

Skill level:
Moderate

Other People Are Reading

Instructions

  1. 1

    Launch Microsoft Visual Basic Express, click "New Project..." on the left pane of your screen and double-click "Windows Forms Application" to start a new project.

  2. 2

    Double-click the form to create a new form load event and add the following code to create a new picture box variable:

    Dim picBox As New PictureBox

  3. 3

    Define the path for the image you want to show using the new picture box.

    picBox.Image = Image.FromFile("C:\Photos\image.jpg")

  4. 4

    Apply some settings to your picture box control by adding the following code:

       picBox.Visible = True
    
        picBox.Top = 20
    
        picBox.Width = 1600
    
        picBox.Height = 1200
    
        picBox.Left = 10
    
  5. 5

    Add the picture box control to your form.

        Controls.Add(picBox)
    
  6. 6

    Press "F5" to run your program and display the new picture box control with your picture.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

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