Adding a PictureBox lets you display an image in your Visual Basic, or VB, program. User interaction with the program's interface may require an image change, such as when selecting a different object from a menu or clicking a button that loads new content. You can use the "FromFile" method to change which image the PictureBox is displaying.
- Skill level:
- Moderately Easy
Other People Are Reading
Open your VB source file in an editor, such as Microsoft Visual Studio Express.
Add a function to handle an event that will activate the PictureBox image change. For example, using a button named "Button2", add the code "Private Sub Button2_Click(ByVal sender as System.Object, ByVal As System.EventArgs) Handles Button2.Click."
Change the PictureBox image by adding the code "MyPictureBox.Image = Image.FromFile("myimage.jpg")." Replace "myimage.jpg" with the image path of your file. The "FromFile" method will load your image into the PictureBox.
Close the function by adding the code "End Sub."
Save the VB file, compile and run it to see your PictureBox image change.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for