Results 1 to 4 of 4

Thread: VB - Three ways to pause your program

  1. #1

    Thread Starter
    Hyperactive Member BrandonTurner's Avatar
    Join Date
    Sep 2001
    Location
    East Lansing, Michiagn
    Posts
    268

    VB - Three ways to pause your program

    VB Code:
    1. Sub Sleep(ByVal MillaSec As Long, Optional ByVal DeepSleep As Boolean = False)
    2.     Dim tStart#, Tmr#
    3.     tStart = Timer
    4.  
    5.  
    6.     While Tmr < (MillaSec / 1000)
    7.         Tmr = Timer - tStart
    8.         If DeepSleep = False Then DoEvents
    9.     Wend
    10. End Sub

    VB Code:
    1. Declare Function GetTickCount Lib "kernel32" () As Long
    2.  
    3. Sub Pause(HowLong As Long)
    4.     Dim u%, tick As Long
    5.     tick = GetTickCount()
    6.    
    7.     Do
    8.       u% = DoEvents
    9.     Loop Until tick + HowLong < GetTickCount
    10. End Sub

    VB Code:
    1. 'shortest
    2. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

  2. #2
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: VB - Three ways to pause your program

    7 way :the best(vb6 delay)pause,doevents(no need cpu)
    http://www.vbforums.com/showthread.p...pu)&highlight=

  3. #3
    New Member
    Join Date
    Apr 2023
    Location
    Adelaide, South Australia
    Posts
    13

    Re: VB - Three ways to pause your program

    1. 'shortest
    2. Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds as Long)

    you missed part of it

  4. #4
    PowerPoster VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    2,626

    Re: VB - Three ways to pause your program

    You don't need the "Alias" part unless your chosen name is different from the actual API function name.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width