peraphs just post, but not found...
i remember only a static or boolean condition..
i need to click to go my sub and if i reclick goto mysub1...
click and unclick on button
-
- Administrator
- Posts: 78524
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: click and unclick on button
Something like this:
Alternatively, use the caption of the button:
Code: Select all
Private Sub MyButton_Click()
Static f As Boolean
f = Not f
If f Then
Call MySub
Else
Call MySub1
End If
End Sub
Code: Select all
Private Sub MyButton_Click()
If MyButton.Caption = "This" Then
Call MySub
MyButton.Caption = "That"
Else
Call MySub1
MyButton.Caption = "This"
End If
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: click and unclick on button
NICE!HansV wrote: ↑06 Sep 2021, 07:40Something like this:
Alternatively, use the caption of the button:Code: Select all
Private Sub MyButton_Click() Static f As Boolean f = Not f If f Then Call MySub Else Call MySub1 End If End Sub
Code: Select all
Private Sub MyButton_Click() If MyButton.Caption = "This" Then Call MySub MyButton.Caption = "That" Else Call MySub1 MyButton.Caption = "This" End If End Sub
-
- 4StarLounger
- Posts: 559
- Joined: 27 Jun 2021, 10:46
Re: click and unclick on button
>click and unclick on button
Sounds to me like you are trying to implement t your own version of a togglebutton - which already exists for userforms, and they already have the equivalent of a static variable representing current status. So you can go with
Sounds to me like you are trying to implement t your own version of a togglebutton - which already exists for userforms, and they already have the equivalent of a static variable representing current status. So you can go with
Code: Select all
Private Sub ToggleButton1_Click()
With ToggleButton1
If .Value Then
.Caption = "Clicked"
Else
.Caption = "Unclicked"
End If
End With
End Sub