Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

I cant load jpeg files into PictureBox and ImageBox...help help!

Hi guys,

I have been trying to load a JPEG (.jpeg) picture into a PictureBox and an ImageBox...but then some how I can only load in icons (.ico) into them...how come is it like this? I thought ImageBox supports most image file??

The method I use is:

picPicture1.Picture = _
LoadPicture ("JPEG.jpeg",....) OR

imgImage1.Picture = _
LoadPicture ("JPEG.jpeg",....)

can someone guide me with this? thanks thanks...
[463 byte] By [ootnitsuj] at [2007-11-11 8:02:35]
# 1 Re: I cant load jpeg files into PictureBox and ImageBox...help help!
You are using the wrong syntax, you must set pictures with 'Set'.

Set Image1.Picture = LoadPicture("D:\My Documents\My Pictures\Test.jpg")

Tested fine on my machine, hope it works for you.

Steve. :cool:
Steve Grant at 2007-11-11 17:26:06 >
# 2 Re: I cant load jpeg files into PictureBox and ImageBox...help help!
ok okie...i think i know where is the prob now...i have made a careless mistake...putting the file extension as .jpeg instead of .jpg...

thanks alot steve...

cheers,
justin
ootnitsuj at 2007-11-11 17:27:06 >
# 3 Re: I cant load jpeg files into PictureBox and ImageBox...help help!
Set Image1.Picture = LoadPicture("D:\My Documents\My Pictures\Test.jpg")
You don't need to Set any Image.Picture. It works perfectly without.

It will work just the same if its *.jpeg or *.jpg, they are both picture formats. I've just tried it and proved it. There is something else wrong with your code. ;)

picPicture1.Picture = LoadPicture ("JPEG.jpeg",....)

Thats assuming JPEG.jpeg is in the App.Path. Otherwise you'll get a 53 error File not found. Or was that just an example?
Keithuk at 2007-11-11 17:28:05 >
# 4 Re: I cant load jpeg files into PictureBox and ImageBox...help help!
Oh okie...thanks for the reply Keithuk...

I am able to load in the pictures without using the Set method, and it works fine for me after I have change the .jpeg to .jpg. I need to change the picture during runtime so i have to set the path for the picture to be load during runtime.

Anyway, what exactly is App.path? what is this line about? Can u give me an explanation on this? what is the application path??thanks thanks
ootnitsuj at 2007-11-11 17:29:09 >
# 5 Re: I cant load jpeg files into PictureBox and ImageBox...help help!
You should have to change the .jpeg to .jpg its still a picture. I tried your query yesterday, I only have 1 jpeg on my HD but it loaded as normal.

App.Path is an abbreviation for application path. Thats the folder the exe is running from.

How are you loading these pictures, CommonDialog or FileListBox? ;)
Keithuk at 2007-11-11 17:30:05 >
# 6 Re: I cant load jpeg files into PictureBox and ImageBox...help help!
Hi Keithuk.

I am not using any CommonDialogBox or whatsoever in this project. I simply use a PictureBox to load my desired pics. It works like this:

when the option in the file menu is clicked, then this PictureBox will be loaded with the respective jpeg image. so in other words, i have to specify the exact location of when this jpeg image is so that the PictureBox can be loaded with the desired image.

Like i have stated previously, i use the method:

picHomeTeam.Picture = _
LoadPicture ("C:\Documents and Settings\Justin\Desktop\NewcastleUnitedLogo.jpg")

So the whole implemantation is quite straightforward.

Anyway, i believe if you dun create a .exe in VB, there will not be any .exe icon available right? So what do u mean by "Thats the folder the exe is running from" when i have not even create my .exe file? Do u mean the folder where the project and form files are??

thanks for your replies...
ootnitsuj at 2007-11-11 17:31:15 >