ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   triple state button question (https://www.excelbanter.com/excel-programming/329904-triple-state-button-question.html)

filo666

triple state button question
 
I want to made a triple state button in a customised toolbar, when this
button is pressed the button image is changed to a dog and a macro is run;
when the button is presed again the button image changes to a cat and a
different macro is run, and finally when the button is pressed again a third
macro Is run and the button image changes to a snake, How to accomplish this
(pd. I dont know nothing about how to operate menu bars and buttons with VB)?


Henry[_5_]

triple state button question
 
You mean four states ( the starting state, Dog, Cat and Snake).
Assuming that your button starts off with a picture of a mouse, try this.

In the general area (above the Sub) put Public MyState


Private Sub Mybutton_click()
Select Case Mystate

Case 0
'Change picture to Dog
Run your code For Mouse (if any)
MyState = Mystate +1

Case 1
'Change picture to Cat
Run code for Dog
MyState = MyState +1

Case 2
'Change picture to Snake
Run code for Cat
MyState =MyState +1

Case 3
'Change picture to Mouse
Run code for Snake
MyState = 0

Case Else
'Change picture to Mouse
MyState = 0

End Select

End Sub


HTH

Henry

"filo666" wrote in message
...
I want to made a triple state button in a customised toolbar, when this
button is pressed the button image is changed to a dog and a macro is run;
when the button is presed again the button image changes to a cat and a
different macro is run, and finally when the button is pressed again a
third
macro Is run and the button image changes to a snake, How to accomplish
this
(pd. I don't know nothing about how to operate menu bars and buttons with
VB)?





All times are GMT +1. The time now is 05:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com