473,805 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delay Function in VB6

Ali Rizwan
925 Contributor
Hello all,
I want to put delay in my loops as we use in c/c++..
Is there any delay function in vb6 which put delay between any code???

Thanx
>> ALI <<
Mar 6 '08 #1
3 22368
jamesd0142
469 Contributor
Hello all,
I want to put delay in my loops as we use in c/c++..
Is there any delay function in vb6 which put delay between any code???

Thanx
>> ALI <<
Try:

system.threadin g.thread.sleep( miliseconds)
Mar 6 '08 #2
Killer42
8,435 Recognized Expert Expert
Try:

system.threadin g.thread.sleep( miliseconds)
I wouldn't try that in VB6, you might hurt yourself. :)

You might want to look into API calls such as SleepEx.

As for plain VB, I used to have a simple routine I wrote for jsut this kind of situation. I'll throw together another one now. Note that you would be better off finding a way to call the Windows "put this thread to sleep" function(s). Looping and calling DoEvents from VB causes a bit of an odd situation. It appears to chew up a huge amount of CPU. But since all it's doing is telling Windows repeatedly to "ignore me and go do your own thing" it doesn't (as far as I can tell) slow anything down. In other words, if you hear the CPU fan rev up, or see your CPU monitor suddenly hit 50% or 100%, don't panic. :)

Expand|Select|Wrap|Line Numbers
  1. Public Sub SleepFor(ByVal Seconds As Double)
  2.   ' "Sleep" for the specified number of seconds.
  3.   Dim EndTime As Date
  4.   EndTime = DateAdd("s", Seconds, Now)
  5.   Do
  6.     DoEvents
  7.   Loop Until Now >= EndTime
  8. End Sub
  9.  
Note: I wrote this in VB6 IDE just now, so the syntax should be correct. But it hasn't been tested.

to use it, just code
Expand|Select|Wrap|Line Numbers
  1. SleepFor 1.5 ' Pause for 1½ seconds.
  2.  
Mar 7 '08 #3
Ali Rizwan
925 Contributor
Thanx for helping me.
>> ALI <<
Mar 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
18887
by: Shuo Xiang | last post by:
Greetings: I'm working on some graphical game and need to animate certain things (by continuously changing the x/y coordinate and update the display), however, the system is blinkingly fast so no actual animations can be seen. Therefore I need a "delay" function. Is there a "delay" function in C++ that accepts a time argument in seconds or its varieties (i.e. so that I don't have to resort to the "big for loop" scheme). Regards,
2
16413
by: amos_s12 | last post by:
Hello everybody Is there a possibility to make a delay between two sql statements, namely one sql statement is performed, then there is a delay of some seconds and then rhe next statement is performed. In sybase database, there is a possibility to do such thing by using the statement waitfor delay 'hh:mm:dd' for example: while(...)
6
5565
by: lucifer | last post by:
hi i need to insert delay in my program what function should i use the old delay is not supported by the VC6
18
3272
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep function from kernel32 to accomplish this? My concern is that this function takes milliseconds where my program needs to be accurate to within 5 minuets, and delays may be as long as a number of days, months or whatever. Would I run into many problems...
9
2359
by: krbyxtrm | last post by:
hello i have this profile for iterating empty vectors: +0.3us (microsecond) delay on intel pentium 2.4Ghz can this added delay to my application be reduced? i mean near zero delay, its very important. BTW, does anyone has another profile for this? thanks.
1
2064
by: dsloan | last post by:
This problem is very similar to that experienced in http://www.thescripts.com/forum/thread147783.html, but the solution there doesn't seem to apply here. I have a function which works fine with the alert call in place below, but a delay (using another function defined elsewhere, which does work by the way) doesn't. Similarly if no delay is put in place it fails to complete the next line. It certainly appears that a value hasn't been finalised...
4
782
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There is no built-in way to pause execution in javascript such as a sleep function, but hosts usually provide a method of some form. Web browsers are designed for event driven programming and only provide the « setTimeout » and « setInterval »...
1
7010
by: maul581 | last post by:
I know the delay( ) function of Turbo C and used it in my project. By this function we can give intermediate delay in execution from 1 millisecond to 9999 millisecond. My main question is "Is it possible to get delay less than 1 millisecond in Turbo C"? If by changin any header file (e.g. dos.h) or by creating my own "delay" function, at any way Can I get delay less than 1 millisecond? If in C it is not possible than please suggest me any...
1
2975
by: maul581 | last post by:
I know the delay( ) function of Turbo C and used it in my project. By this function we can give intermediate delay in execution from 1 millisecond to 9999 millisecond. My main question is "Is it possible to get delay less than 1 millisecond in Turbo C"? If by changin any header file (e.g. dos.h) or by creating my own "delay" function, at any way Can I get delay less than 1 millisecond? If in C it is not possible than please suggest me any...
6
7949
by: sheldonlg | last post by:
I came across a problem and googling for an answer didn't help. What I want to do is run an AJAX script that sets a hidden variable on the form. I call the AJAX script from a javascript function. After the call, I check the value of that hidden variable and proceed according to whether it is zero or one. The problem is that the AJAX call does not complete before the test. So, I put in a delay after the call to the AJAX function. I...
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.