我正在尝试将字符串传递给计时器并且不知道如何...这是我当前的代码。
Private Sub PTID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PTID.Click
Dim Placeholder As String = PTID.Text
My.Computer.Clipboard.SetText(Placeholder)
PTID.Text = "Copied to Clipboard"
ClipboardTimerPaymentTech.Start()
End Sub
Private Sub ClipboardTimerPaymentTech_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClipboardTimerPaymentTech.Tick
PTID.Text = Placeholder
ClipboardTimerPaymentTech.Stop()
End Sub
这样做,将文本保存到字符串。将文本框更改为已复制的alart用户,然后将其设置回原始文件。这是我能想到的唯一方法,如果你有更好的方法,请告诉我。否则,我如何将“占位符”字符串传递给计时器?
谢谢!
编辑:我知道我可以做一个Threading.sleep,但我不想让程序被锁定
答案 0 :(得分:1)
您可以使用文本框Tag属性,而不是创建另一个变量
Private Sub PTID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PTID.Click
PTID.Tag = PTID.Text
My.Computer.Clipboard.SetText(PTID.Text)
PTID.Text = "Copied to Clipboard"
ClipboardTimerPaymentTech.Start()
End Sub
Private Sub ClipboardTimerPaymentTech_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClipboardTimerPaymentTech.Tick
PTID.Text = PTID.Tag
PTID.Tag = ""
ClipboardTimerPaymentTech.Stop()
End Sub