Hi,

I have a problem. I have put up an image on a form of .jpeg format.(copy and pasted).. But when i save it... it works fine at home.. .when i copy it on a cd... it is not saving the background image. Rather ... when I try to open it on an other computer.. the background image is gone. I'm not finding any reason ..why thats happening.. i'd be glad if someone can help me. Should i save the image on the other computer too and give a path name or something using code?? If yes... what is the code like? Please help me. And why does it happen so? Thank you.Forgot to add this... i'm using vb6.

There is a couple of solutions.... one is to put the picture in the same folder as the VB EXE that is going to be running it. And then use the code

form1.picture = app.path & "\picturename.jpg"

Another alternative, is to use a picturebox.... and set it's attributes to hidden. Set it's pictures property to the image you want. You should be able to get away without having to move the file around everywhere. Copy and paste.... you should be able to paste it into a picture box... but I'm not positive. Anyway, if you use a picture box, you could set the form with:

form1.picture = picture1.picture

Let me know what you think.

the best way to do it is to link to the file outside as said above, just ensure that the path is correct and always links to the right file.

Well, That depends entirely on portability, and what you are after. If you want it to be contained within the EXE... so you don't have to try to keep track of such and such.jpg, then it would be better to do it in a picturebox. The drawback to this, is EXE file size, and loading time... but ultimately, it's a matter of what you are trying to accomplish.

Thanks a lot for your suggestions. I'll try and let you know soon. Thanks again.

Hi again,

Can you tell me.. whats wrong with this code...

Private Sub Form_Load()
Form1.Picture = App.Path & "\096.jpg"
End Sub

There is nothing wrong with that code.... UNLESS:

1) the form that you are trying to load the image to is NOT called form1
2) the file "096.jpg" is NOT in the same folder as the EXE file you created.

Now, On the second note, (I don't remember the path, but you could do a msgbox app.path to find out), the file 096.jpg MUST BE IN THE SAME FOLDER as the program. If you make the program an EXE (file, make exe) then that EXE must be in the same folder as the picture file when the program runs, in order for it to work. If you are using the VB IDE (clicking start, and running it from within VB) then you'll have to know the path that it's running, and put the picture file there.

Hi,

Private Sub Form_Load()
Form1.Picture = App.Path & "\096.jpg"
End Sub

It is giving a compile error at & as type mismatch.

Where am i wrong . Please help.

K. Change the & to a +

Form1.Picture = App.Path a + "\096.jpg"

its giving a syntax error

Form1.Picture = App.Path  + "\096.jpg"

does it work!? :)

Hi,
Try this one if it works:

Form1.Picture = LoadPicture(App.Path & "\096.jpg")

hope it work.

Newvbguy

does it work!? :)

type mismatch :sad:

Hi,
Try this one if it works:

Form1.Picture = LoadPicture(App.Path & "\096.jpg")

yes, this worked.. thanks.

Did you try the loadpicture method that vbnewguy suggested?

i use an image box to utilize the stretch property.

works for me...

Image1 = LoadPicture(App.Path & "\096.jpg")


C

Private Sub Command1_Click()
CommonDialog1.ShowOpen
Image1.Picture = LoadPicture(CommonDialog1.FileName)

End Sub

i hope it woks !!

but how the filename is from the textbox ? like this ?

Image1.Picture = LoadPicture(folder & "\" & Text1.Text)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.