Results 1 to 6 of 6

Thread: Delay command in VB??

  1. #1
    Stiletto
    Guest

    Delay command in VB??

    sups,
    Is there a Delay command in VB like the Delay command in Pascal?
    I got progressbars in my project which mesuring the progress of commands...and ofcourse its going very very quick, so i'm wondering if there is a Delay command in VB i can use, to make the progress a lil slower, so the user will b able to view the changes in the process...?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    you don't want a delay, you want DoEvents

  3. #3
    Stiletto
    Guest
    what DoEvents does?

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    look it up...
    Yields execution so that the operating system can process other events.

    Syntax

    DoEvents( )

    Remarks

    The DoEvents function returns anInteger representing the number of open forms in stand-alone versions of Visual Basic, such as Visual Basic, Professional Edition. DoEvents returns zero in all other applications.

    DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.

    DoEvents is most useful for simple things like allowing a user to cancel a process after it has started, for example a search for a file. For long-running processes, yielding the processor is better accomplished by using a Timer or delegating the task to an ActiveX EXE component.. In the latter case, the task can continue completely independent of your application, and the operating system takes case of multitasking and time slicing.

  5. #5
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    how long is the delay with DoEvents? cos i know in C++, with the Sleep(), you can specify how long
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You can use Sleep API in VB, but it will hog processing power, unlike DoEvents which gives power back to the OS so it can processes pending messages in message queues (esp the progressbar one in this case)

    The delay DoEvents gives depends on how many messages there are to process, and how much each consumes.

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