How to show and hide a picture on a button at runtime?

M

Mark Stephens

Hi,

I want to have a piccture on a button and make it invisible and visible when
another button is clicked. I have put the picture on the button by copying
it and then selecting picture in the properties of the button (which is on a
userform) and then ctl v.

Any tips appreciated, thanks and regards, Mark
 
R

Rick Rothstein

Assuming the button you want to have the picture on is named CommandButton1
and the name of the "other button" is CommandButton2... then use this
CommandButton2 Click event (replace my sample path to the picture with your
actual path to the picture in the LoadPicture function call)...

Private Sub CommandButton2_Click()
If CommandButton1.Picture = 0 Then
CommandButton1.Picture = LoadPicture("C:\Dir1\Dir2\Pic.bmp")
Else
CommandButton1.Picture = LoadPicture("")
End If
End Sub
 
M

Mark Stephens

Thanks Rick, works really well:)

Mark



Rick Rothstein said:
Assuming the button you want to have the picture on is named
CommandButton1 and the name of the "other button" is CommandButton2...
then use this CommandButton2 Click event (replace my sample path to the
picture with your actual path to the picture in the LoadPicture function
call)...

Private Sub CommandButton2_Click()
If CommandButton1.Picture = 0 Then
CommandButton1.Picture = LoadPicture("C:\Dir1\Dir2\Pic.bmp")
Else
CommandButton1.Picture = LoadPicture("")
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top