i got this code in vb6
Private Sub pause(ByVal interval As Variant)
Dim Current As Variant
Current = Timer
Do While Timer - Current < Val(interval)
DoEvents
Loop
End Sub
How do I convert in vb.net? I have tried this way but it doesn't works.
Where is the mistake?
Private Sub pause(ByVal interval As Single)
Dim newDate As Date
newDate = DateAndTime.Now.AddSeconds(interval)
While DateAndTime.Now.Second <> newDate.Second
Application.DoEvents()
End While
End Sub
Thanks
I think the following is the best conversion of the original code (subtly different to andygrips answer):
Private Sub Pause(ByVal seconds As Integer)
Dim current As Date
current = DateTime.Now
Do While (DateTime.Now - current).TotalSeconds < seconds
Application.DoEvents()
Loop
End Sub
Note however that the use of DoEvents in .NET is best avoided altogether