This example changes the Caption property of a CommandButton control each time the user clicks the button. To try this example, paste the code into the Declarations section of a form containing a CommandButton named Command1, and then press F5 and click the button.
Private Sub Command1_Click ()
' Check caption, then change it.
If Command1.Caption = "Clicked" Then
Command1.Caption = "OK"
Else
Command1.Caption = "Clicked"
End If
End Sub