Tuesday 23 July 2013

Upload image in picturebox using vb.net


    Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        Try
            Dim file As New OpenFileDialog()
            file.Filter = "Image FilesImage Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp"  'you can 'ad more extension
            If (file.ShowDialog() = DialogResult.OK) Then
                Dim filename As String = System.IO.Path.GetFullPath(file.FileName)
                picBox.Image = New Bitmap(file.FileName)
                Me.picBox.SizeMode = PictureBoxSizeMode.StretchImage
            End If
        Catch ex As Exception
        End Try
    End Sub

Followers