views:

39

answers:

3

I'm having difficulty coding in vb2005 for searching an image for my database storage.

I made a employees system and i use to add picture to it, same with all of the his personal data.

I want to make a button that will look for a file in mycomputer for an image to store in my picture box.

Can anyone help me in this code.

thanks in advance.

A: 

If you are trying to search your entire hard drive for image files, you may want to look at this code example.

http://bytes.com/topic/net/answers/102603-searching-files-vb-net

RichO
A: 

Use this:

  using (FolderBrowserDialog browserdialog = new FolderBrowserDialog())
{
    if (browserdialog.ShowDialog(this) == DialogResult.OK)
    {
        string ThisIsYourImageFileLocationString = browserdialog.SelectedPath;
    }
}

You're enduser will have a small window open up and he'll navigate to the picture he wants to add. Then, it's just a matter of coding in the:

pictureBox1.Image = ThisIsYourImageFileLocationString;
Sergio Tapia
A: 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Using dlg As New OpenFileDialog
     dlg.Filter = "Image Files (*.jpg,*.gif,*.bmp)|*.jpg;*.gif;*.bmp"
     dlg.Title = "Select an image file"
     If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
        Me.PictureBox1.Image = Image.FromFile(dlg.FileName)
     End If
  End Using

End Sub