[英]Toggle Button in Visual Studio (VB.NET)
我想制作一个切换按钮来暂停和启动某件事。 到目前为止,这是我的代码:
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
文本将更改为“暂停”,但不会更改回“播放”。 有人可以帮助我并使它正常工作吗?
不需要布尔值,只需检查文本即可:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.