Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27374

Picture box problem

$
0
0
Hello, I have another problem with my project. I have a form, that saves image from computer to databese. Saving, deleting all works except this. When you click button to open windows search (to find picture from computer), if you click "Cancel" it shows a mistake. Here is my code:

Code:

    Private Sub ButtonOPEN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOPEN.Click
        OpenFileDialog1.ShowDialog()

        TextBox1.Text = OpenFileDialog1.FileName

        ChosenPicturePictureBox.Image = Image.FromFile(TextBox1.Text)
    End Sub

So if I click "Cancel", application stop working and line this row of code: ChosenPicturePictureBox.Image = Image.FromFile(TextBox1.Text) so that is here mistake. Open button works normal.

Also, how do I prevent to chosing other files exceot JPEG files.

Realy thanks for all idea.

Viewing all articles
Browse latest Browse all 27374

Trending Articles