Working With Resource File

Lesson 1
Tutorials - Page 1 - Page 2 - Page 3 - Page 4 - Page 5 - Page 6 - Page 7 - Page 8 - Page 9 - Page 10

Accessing BMP, ICO and CUR files from your Program - Examples
The next example will show you how to add an icon to Command Button from resource file.

Add an Icon to your Resource File (under the Icon "Folder") and rename its ID to "myIcon".
Add 1 Command Button to your form (named Command1).
Set the Command Button Style property to 1 - Graphical, so it will be able to display images.
Add the following code to your form:

Private Sub Form_Load()
    Command1.Picture = LoadResPicture("myIcon", vbResIcon)
End Sub

Run the program, and you will see that the icon is displayed on the Command Button.

You can load multiple Icons on multiple Command Buttons, and load multiple Bitmaps into multiple Picture Boxes at the same time, as demonstrated below:

Image 17:

Back  Forward