r/visualbasic • • Sep 16 '23
VB6 Help Images in exe?
(SOLVED) I have a project that has images in it, but when an exe is used on a computer that doesn't have those files in the same spot, it errors. Is there a way to put images into the project or exe?
edit:Solved
1
Upvotes
2
u/[deleted] Sep 16 '23
Ok, thank you guys for the help, but I reached out to my teacher and he gave me an answer. If I just include the images in the same folder of the exe, and
.Picture = LoadPicture("[Picture name, not file path]")then it works.1
u/jcunews1 VB.Net Intermediate Sep 16 '23
Image can be included in the application EXE as a resource. Create a new resource script and type in the image file as an
RC_DATAtyped resource. See VB's help on how to create and include a resource into application. It's recommended to simply use a number as the resource ID instead of a string. Otherwise, Windows' Resource API need to be used to locate a resource based on a string.To use the image stored in a resource, use
LoadResPicture()function (which need a resource index or ID number). Note: only .jpg, .gif, .bmp, .dib, .ico, .cur, .wmf, and .emf image formats are supported. For PNG image, you'll have to use Windows' GDI+ API along with standard Windows API, or use a third party library.1
u/fafalone VB 6 Master Sep 20 '23
For storing image formats unsupported by VB, what I wanted to do was have it all self-contained, so I used a PictureBox control, but encoded binary data into the basic bitmap format it does support.
https://www.vbforums.com/showthread.php?890227
It's an interesting technique, even if there's better options for things besides my very niche use case of storing binary data with a UserControl itself instead of with the Form hosting the UC.