Thanks to one of your old questions, I started this code:
Dim fd As OpenFileDialog = New OpenFileDialog()
Dim strFileName As String
fd.Title = "Please select an image"
fd.InitialDirectory = "C:\Users\"
fd.Filter = "PNG Images (*.png*)|*.png*|JPG Images (*.jpg*)|*.jpg*|JPEG Images (*.jpeg*)|*.jpeg*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then
strFileName = fd.FileName
Dim ImageTest As Image
ImageTest = fd.FileName
PictureBox1.Image = ImageTest
End If
Except that ImageTest
is not functional. It gives me the error:
Cannot convert String to Image.
How do I get the user to select a personal image with an OpenFileDialog
?