Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to update image in imagebox at click of a button

Status
Not open for further replies.

drrep

Programmer
Mar 13, 2002
47
0
0
US
Hi everyone,

I want to have a button that will, when pressed, ask for a filename of an image (bmp file) and then update the image box that I have on my form thereafter.

I know I can use an inputbox to get the filename but how do I update the imagebox after that with the new filename?
 
Try using a common dialog control to allow the user to browse to the imamge file. Thanks and Good Luck!

zemp
 
Thanks but how does it link the chosen file name to the image box so it can be updated with the chosen image?
 
To update an image box control just assign the name of the file to the image boxes .picture property.

Image1.Picture = CommonDialog1.Filename Thanks and Good Luck!

zemp
 
Sorry zemp,

you need to use

Image1.Picture = loadpicture(CommonDialog1.Filename)

All the best Praveen Menon
 
I stand corrcted. Thanks for catching that PraveenMenon, it has been a while since I have dealt with images. Thanks and Good Luck!

zemp
 
One more thing zemp and drrep, you need to catch the cancel error while using the commondialog.

if commondialog1.filename<>&quot;&quot; then

Image1.Picture = loadpicture(CommonDialog1.Filename)

end if

this is to catch the error when the user cancels the dialog

All the Best
Praveen Menon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top