我的Button1带有以下代码:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label2.Text = ""
Label3.Text = ""
Label4.Text = ""
End Sub
并且想要延迟单击button2时调用button1,例如,在20秒后单击button2时应用button1。
在button2代码中:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Button1_Click(sender, e)
Label6.Text = ""
End Sub
我该如何延迟时间,所以先清除label6.text,然后延迟后清除labe2和3和4。
答案 0 :(得分:0)
正如汉斯指出的那样,避免调用另一个按钮。创建两个按钮都可以使用的私人子。然后使用计时器进行20秒的延迟。像这样:
'Declare a timer with a tick rate of 20 seconds
Dim Timer As New Timer With {.Interval = 20000}
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ClearLabels2To4()
End Sub
'Create this as a separate sub, so it can be used by both buttons.
Private Sub ClearLabels2To4()
Label2.Text = ""
Label3.Text = ""
Label4.Text = ""
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ClearLabels2To4()
'Start the 20 second timer
Timer.Start()
End Sub
Private Sub Timer_Tick(sender As Object, e As EventArgs)
Label6.Text = ""
'Stop the timer so it doesn't continually fire every 20 seconds
Timer.Stop()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
'Create a handler for the timer ticks
AddHandler Timer.Tick, AddressOf Timer_Tick
End Sub
答案 1 :(得分:0)
如果您想使用按钮或需要使用按钮,可以使用以下代码。
showSport() {
const tmpSport = this.props.sports.find(item => item.id === this.props.directory.typeSport);
return tmpSport.name; // error is here!
}
render() {
return (
<div>
<div>{this.props.directory.surname}</div>
<div>{this.showSport()}</div>
</div>
);
}
以下链接提供了一种暂停或延迟过程the link的方法。
希望它会有所帮助。谢谢。