Upload Image in PictureBox

We are fond of uploading so many images in websites, programs, etc. But, the good thing is that we can make this program. We will just use the OpenFileDialog in VB.NET. So, now let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add one PictureBox named PictureBox1 so that the image will be displayed in PictureBox. Add also a Button named Button1 so that we can open the file that we are going to upload. 3. Add the OpenFileDialog in your toolbox. Follow the image below. open 4. You must design your layout like this: design 5. Put this code in your Button1_Click:
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim OpenFileDialog1 As New OpenFileDialog
  3.      
  4.         OpenFileDialog1.Filter = "Picture Files (*)|*.bmp;*.gif;*.jpg"
  5.         If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  6.             PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
  7.         End If
  8.     End Sub

Explanation:

We initialized OpenFileDialog1 as our OpenFileDialog because it will provide a dialog box that enables the user to select one or more files, as seen in the image below. OpenFileDialog1.Filter = "Picture Files (*)|*.bmp;*.gif;*.jpg" - this syntax filters the opening of files that can be viewed and open in your OpenFileDialog. Open file Dialog If we click the Open button with the desired image to click then it will upload into the PictureBox Image as we code PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)

Output:

output Download the source code below and try it! :) For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Comments

This has nothing to do with upload of a Picture. Just common load a picturebox.

hey, can you give me a turorial for vb6

Add new comment