Beginning Resource Files
Open the code window for this form and paste the following code:
Private Sub Command1_Click()'Here is where we alternate the icons and the captions If Command1.Caption = "Start" Then Command1.Picture = LoadResPicture(101, vbResIcon) Command1.Caption = "Stop" Else Command1.Picture = LoadResPicture(102, vbResIcon) Command1.Caption = "Start" End If End SubPrivate Sub Form_Load()' paste the icon on the face of the command button' and set the caption. Look in the online help for' additional information on the second parameter Command1.Picture = LoadResPicture(102, vbResIcon) Command1.Caption = "Start" Show End Sub
Press F5 and run it. Click on the button a few times.
I bet you feel that this is an awful lot of running around just to change an icon. Well, it isnt.
Page 4 of 5
This article was originally published on November 20, 2002