Working With Resource File
ICO and CUR files from your
Now you have the resource file with all your
image files in it.
But how can you access them from your
Start a new Project, add 1 Picture Box (named Picture1) to
your form, and add the following code to the form:
Private Sub Form_Load()
Picture1.Picture = LoadResPicture(101, vbResBitmap)
This code will load
the Bitmap that found under the Bitmap "Folder" in the resource file, with the
ID 101, to the Picture Box.
Explanation of this code:
LoadResPicture function load a picture
from the resource file.
101 - the ID of the picture you want to
load. if there is no Bitmap in your resource file with the ID 101, an error
If your picture ID is a word like "Cube" instead of number
like 101, you should write:
Picture1.Picture = LoadResPicture("Cube",
Note that the "Cube" is in quotes, and when the ID was a
number it was not in quotes.
vbResBitmap - Because the picture you want
to load is a Bitmap, and it's under the Bitmap "Folder" in the resource
If you want to load an icon with the ID
"myIcon", use LoadResPicture("myIcon", vbResIcon)
and if you want to load
an cursor with the ID "myCursor" use
To load BMP, Ico or Cur
file from resource file use:
Where vbRes...=vbResBitmap if it's Bitmap
vbRes...=vbResIcon if it's Icon file,
vbRes...=vbResCursor if it's cursor file.
Examples in the next page...