Changing Text on a Button

PMorgan983

New member
Joined
Mar 10, 2004
Messages
2
I am having problems changing text on a button when it is clicked. I am trying to create a start/stop button that displays "Start" initially, changes to "Stop" when clicked, and changes back to "Start" when it is clicked again.

Right now, I can get it to change from "Start" to "Stop", but not back to "Start" again.

Thanks!
 
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click

if btnStop.text = "Start" then
btnStop.text = "Stop"
else
btnStop.text = "Start"
end if

End Sub


Or if you want to flag it...

Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click

Dim btnFlag as boolean = False Stop is default btnStop.text

if btnFlag = False then
btnStop.text = "Start"
btnFlag = True
else
btnStop.text = "Stop"
btnFlag = False
end if

End Sub


or use negation if not ....etc etc etc....
 
Last edited by a moderator:
Back
Top