问题
Dim ImagePath As String = "images/spaceship2.png"
Dim img1 As Bitmap
Dim newImage As Image = Image.FromFile("images/spaceship2.png")
img1 = New Bitmap(ImagePath)
pb2.ImageLocation = ImagePath
pb1.Image = newImage
I want to display image from folder, for example, student with an id number of 22137471, the picture with the name of 22137471 will be display on my picture box, between, i saw this code somewhere in google.
回答1:
i want to display image from folder, for example, student with an id number of 22137471, the picture with the name of 22137471 will be display on my picture box
Try something like...
Dim id As String = "22137471"
Dim folder As String = "c:\some path\folder"
Dim filename As String = System.IO.Path.Combine(folder, id & ".png")
PictureBox1.Image = Image.FromFile(filename)
回答2:
You can try this:
PictureBox1.Image = Image.FromFile("c:\some path\folder\myImage.jpg")
来源:https://stackoverflow.com/questions/19748868/displaying-image-from-folder-file-in-vb-net