I have a vb.net form+button+textbox + delay sub:
'DELAY SUB
Public Sub Delay(ByVal Milliseconds As Integer)
Dim Stop_Watch_2 As New Stopwatch
Stop_Watch_2.Start()
Do
Loop Until Stop_Watch_2.ElapsedMilliseconds >= Milliseconds
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For i = 1 To 10
Delay(2000) ' 2 second delay
Text_Box1.text = i.ToString
Button1.Left = Button1.Left + 30
Next
End Sub
When I run the form, I can see the button is moving to the left every two seconds. The button moving on delay is OK, but the text is not taking the loop value. This delay method for me is better than thread.Sleep
.
Any suggestions on how to let the text box update its content after the delay interval?
thread.Sleep
.TextBox
is "taking" it, it likely not repainting every update. AddText_Box1.Refresh()