I wanted to make a toggle button for pausing and starting something. This is my code so far:
Private Sub playpause_Click(sender As Object, e As EventArgs) Handles playpause.Click
Dim ispaused As Boolean = True
If ispaused = True Then
playpause.Text = "Pause"
ispaused = False
Else
playpause.Text = "Play"
ispaused = True
End If
End Sub
The text changes to Pause, but it doesn't change back to Play. Can someone help me and get this to work?
No boolean needed, just check the text:
Private Sub playpause_Click(sender As Object, e As EventArgs) Handles playpause.Click
If playpause.Text = "Pause"
playpause.Text = "Play"
'do stuff for pause
Else 'it was "Play"
playpause.Text = "Pause"
'do stuff for play
End If
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.