Important alert: (current site time 7/16/2013 5:33:52 AM EDT)
 

VB icon

A form of delay

Email
Submitted on: 7/12/2000 8:48:40 AM
By: Niel Corns  
Level: Beginner
User Rating: By 4 Users
Compatibility: Delphi 5, Delphi 4
Views: 12371
author picture
(About the author)
 
     This procedure is similar to the delay function in pascal...it continues with the rest of the application processes while it waits too..
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
!**************************************
! Name: A form of delay
! Description:This procedure is similar to the delay function in pascal...it continues with the rest of the application processes while it waits too..
! By: Niel Corns
!
!This code is copyrighted and has! limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=124&lngWId=7!for details.!**************************************

procedure Delay(ms : longint); 
var 
 TheTime : LongInt; 
begin 
 TheTime := GetTickCount + ms; 
 while GetTickCount < TheTime do
Application.ProcessMessages; 
end;


Other 16 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/26/2002 9:22:18 PMWould'nt this be better if it was:

procedure Delay(ms : longint);
begin
while GetTickCount < (GetTickCount + ms) do
Application.ProcessMessages;
end;
(If this comment was disrespectful, please report it.)

 
5/3/2003 11:36:54 AMAkede

Well, IMHO, no. Not at all. :) Infinite loop. GetTickCount will -ALWAYS- be less than GetTickCount+ms. Not only that, but if it would work like that, it's better to store the value in a variable rather than calling GetTickCount each iteration, which there could be thousands upon thousands.

-Mike
(If this comment was disrespectful, please report it.)

 
11/13/2009 7:23:08 AMWouldtnt this be better?

Procedure Delay (X:LongWord);
Var
Y : LongWord;
Begin
For Y := 0 To Y Do
Begin
Sleep (1);
Application.ProccessMessages;
End;
End;
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.