The Picture Viewer Project

The first step is to create a menu with an item to select a picture.

Start a new Visual Basic Form Application and name it PictureViewer.

Add the following controls to the project:

Build the menu with just one main item, File. Under file add Select Picture. (It will be named SelectPictureToolStripMenuItem)

Double click on the Select Picture menu item and write the code shown below:

Public Class Form1
    Private Sub SelectPictureToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _
      Handles SelectPictureToolStripMenuItem.Click
        OpenFileDialog1.Filter = "Bitmaps|*.bmp|GIFS|*.gif|JPG|*.jpg"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Load(OpenFileDialog1.FileName)
            Me.Text = OpenFileDialog1.FileName
        End If
    End Sub
End Class
Test your program and try opening several different picture formats. Save all before moving on to the next step.
INDEX, Viewing a Picture, Code and instructions to view a picture, Select a folder, Display the picture selected in the combo box, Use a timer to create a slide show
Next lesson: The Pizza Project

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Code and instructions to view a picture