08-11-2012, 11:22 PM
What you could do is use this code when you click buttons for scrolling (Next, Previous, First, Last):
[code2=vbnet]Try
PictureBox1.Image = Image.FromFile(ImageTextBox.Text)
Catch ex As Exception
MsgBox(ex.Message) ' Style your message box a bit, if you want.
End Try[/code2]
When an user clicks the upload button, add this code:
[code2=vbnet]Dim OpenImage As New OpenFileDialog
OpenImage.Title = "Upload your image"
OpenImage.InitialDirectory = "C:\"
OpenImage.Filter = "Images Files|*.jpg;*.png;*.jpeg;*.bmp"
Dim x = OpenImage.ShowDialog()
If x = DialogResult.OK Then
Try
PictureBox1.Image = Image.FromFile(OpenImage.FileName)
ImageTextBox.Text = OpenImage.FileName
Catch ex As Exception
MsgBox(ex.Message) ' Style your message box a bit, if you want.
End Try
End If[/code2]
That is basically it. That's everything you need in order to display an image. If you want to display .GIF images, you need to use StreamWriter, otherwise it will say "Out of Memory". When the form loads, it doesn't matter which file extension the image have, it will show "Out of Memory", so don't add it there. Everything else works like a charm. If this didn't help you totally, it at least gave you some kind of idea how would it work.
[code2=vbnet]Try
PictureBox1.Image = Image.FromFile(ImageTextBox.Text)
Catch ex As Exception
MsgBox(ex.Message) ' Style your message box a bit, if you want.
End Try[/code2]
When an user clicks the upload button, add this code:
[code2=vbnet]Dim OpenImage As New OpenFileDialog
OpenImage.Title = "Upload your image"
OpenImage.InitialDirectory = "C:\"
OpenImage.Filter = "Images Files|*.jpg;*.png;*.jpeg;*.bmp"
Dim x = OpenImage.ShowDialog()
If x = DialogResult.OK Then
Try
PictureBox1.Image = Image.FromFile(OpenImage.FileName)
ImageTextBox.Text = OpenImage.FileName
Catch ex As Exception
MsgBox(ex.Message) ' Style your message box a bit, if you want.
End Try
End If[/code2]
That is basically it. That's everything you need in order to display an image. If you want to display .GIF images, you need to use StreamWriter, otherwise it will say "Out of Memory". When the form loads, it doesn't matter which file extension the image have, it will show "Out of Memory", so don't add it there. Everything else works like a charm. If this didn't help you totally, it at least gave you some kind of idea how would it work.
Also known as Rocketalypse.
System.out.println("I prefer Java.");
System.out.println("I prefer Java.");