8 Replies - 49808 Views - Last Post: 03 August 2007 - 11:45 AM Rate Topic: -----

#1 cire_1803  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 20-September 06

How to display the image in picture/image box?

Posted 02 August 2007 - 03:38 AM

Posted Image

How to display the image in the image box at the left side after i select an image using the Common Open Dialog box?

I must need to press Insert Image button to pop-up the Open dialog Box.


Best Regards
Is This A Good Question/Topic? 0
  • +

Replies To: How to display the image in picture/image box?

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: How to display the image in picture/image box?

Posted 02 August 2007 - 04:14 AM

You can assign the image that is selected from your Open File Dialog box in the following manner. You will access the file path and name using the FileName property of the OpenFileDialog object.
PictureBox1.Image = Image.FromFile(FileDialog.FileName)

Was This Post Helpful? 0
  • +
  • -

#3 cire_1803  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 20-September 06

Re: How to display the image in picture/image box?

Posted 02 August 2007 - 05:10 AM

I tried your code, but i got this error.

Quote

Run time error '438'
Object doesn't support this property or method


And it highlighted this line of code

 pctImage.image = image.FromFile(dbOpen.FileName) 


Quote

Image.FromFile(FileDialog.FileName)


What you mean by this line?

Is the "Image" is a variable type?

This post has been edited by cire_1803: 02 August 2007 - 05:11 AM

Was This Post Helpful? 0
  • +
  • -

#4 tody4me  Icon User is offline

  • Banned
  • member icon

Reputation: 12
  • View blog
  • Posts: 1,398
  • Joined: 12-April 06

Re: How to display the image in picture/image box?

Posted 02 August 2007 - 06:38 AM

Image is an internal VB object. pctImage.image is the VB6 property that you set to the image that you want displayed in the picture box. If the pctImage.Image doesn't exist, you may have a different version of VB or the property may have changed to something like imagesrc or imagesource, and if that's the case just pass the location that was selected into that property.
Was This Post Helpful? 0
  • +
  • -

#5 cire_1803  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 20-September 06

Re: How to display the image in picture/image box?

Posted 02 August 2007 - 06:47 AM

I changed the name of PictureBox to pctImage. That's why i have pctImage.
Then, in pctImage.Image, the image Image is an Internal VB object as what you said.

The image that i want to clarify is the image in Image.FromFile(dbOpen.FileName).

NOTE: dbOpen is the name of the Open dialog.

what does Image mean? is it a variable type? or a built in object?
Was This Post Helpful? 0
  • +
  • -

#6 tody4me  Icon User is offline

  • Banned
  • member icon

Reputation: 12
  • View blog
  • Posts: 1,398
  • Joined: 12-April 06

Re: How to display the image in picture/image box?

Posted 02 August 2007 - 07:24 AM

Image is a built in VB object, the .image should be a property that you set to the image. In VB6 you may need to put the 'set' word in before the line, i remember that for some reason that VB6 didn't like to handle objects well without it.
Was This Post Helpful? 0
  • +
  • -

#7 cire_1803  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 20-September 06

Re: How to display the image in picture/image box?

Posted 02 August 2007 - 03:12 PM

If Image is a built-in VB Object then, i need to make an Image object?

This is my code:
Private Sub cmdInsrt_Click()
	dbOpen.ShowOpen
	dbOpen.Filter = "*.gif | *.jpg"
	pctImage.Image = Image.FromFile(dbOpen.FileName)
End Sub


Can you please revised/debug my code.
Was This Post Helpful? 0
  • +
  • -

#8 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: How to display the image in picture/image box?

Posted 03 August 2007 - 05:26 AM

Sorry, my bad, I forgot this was VB6.

Try this:
pctImage.Picture = LoadPicture(dbOpen.FileName)

Was This Post Helpful? 0
  • +
  • -

#9 cire_1803  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 20-September 06

Re: How to display the image in picture/image box?

Posted 03 August 2007 - 11:45 AM

thanks jayman9. I did the same thing before i read your post.

Its Done.

Thanks to all.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1