delay or wait random time visual basic


SUBMITTED BY: vishaldagar

DATE: July 9, 2017, 5:18 p.m.

FORMAT: Text only

SIZE: 660 Bytes

HITS: 1065

  1. Sub Delay(ByVal dblSecs As Double)
  2. Const OneSec As Double = 1.0# / (1440.0# * 60.0#)
  3. Dim dblWaitTil As Date
  4. Now.AddSeconds(OneSec)
  5. dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)
  6. Do Until Now > dblWaitTil
  7. Application.DoEvents() ' Allow windows messages to be processed
  8. Loop
  9. End Sub
  10. Function randomtime() As Integer
  11. Dim min As Integer = TextBox9.Text
  12. Dim max As Integer = TextBox10.Text
  13. Dim final As Integer = GetRandom.Next(max - min) + min
  14. Label9.Text = final
  15. Return final
  16. End Function
  17. 'then use Delay(randomtime())

comments powered by Disqus