Reputation: 483
I am trying to pass a string to a timer and have no clue how... here is my current code.
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
What this does is, saves text to a string. Changes the textbox to alart user it has been copied, then sets it back to the original. This is the only way I can think to do it, if you have a better way, please let me know. Otherwise, how can I pass the 'Placeholder' string to the timer?
Thanks!
EDIT: I know I could do a Threading.sleep but I do not want the program to be locked up
Upvotes: 0
Views: 57
Reputation: 1908
You can just use the textbox Tag property instead of creating another variable
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
Upvotes: 1