Step 5Add Code
Begin Code
Public Class Form1 Private pic As Bitmap Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog1.FileName = "Select File" OpenFileDialog1.ShowDialog() pic = New Bitmap(OpenFileDialog1.FileName) PictureBox1.BackgroundImage = pic End SubEnd ClassEnd Code
WHAT THE CODE DOES
Public Class Form1 - Defines the form as Public
Private pic As Bitmap - Defines pic As a private bitmap
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click - Defines When The Events Should Occur
OpenFileDialog1.FileName = "Select File" - Makes the file name in the OpenFileDialog say Select File
OpenFileDialog1.ShowDialog() - Shows the OpenFileDialog
pic = New Bitmap(OpenFileDialog1.FileName) - Adds the value of the selected image to pic
PictureBox1.BackgroundImage = pic - Changes the image in ImageBox1 to pic
End Sub
End Class
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|











































