Visual Basic .Net Load Image in PictureBox

Download
Download is available until [expire_date]
  • Version
  • Download 1113
  • File Size 64.25 KB
  • File Count 1
  • Create Date May 7, 2016
  • Last Updated May 7, 2016

Visual Basic .Net Load Image in PictureBox

Visual Basic .Net Load Image in PictureBox

In this program the user is allowed to browse image files such as jpeg, png and gif format, the selected image will then display into the picture box control of vb.net, information of the image such as filename and the path of the image will also be shown in the form.

Source code:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif"

        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = OpenFileDialog1.FileName
            Label2.Text = OpenFileDialog1.SafeFileName
            PictureBox1.ImageLocation = OpenFileDialog1.FileName
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    End Sub
End Class

, , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.