473,513 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB6: delay(100)

Searched on google, but without any succes.
I need a function where I can define how long the PC has to wait until it
executes its next command.

I know that it is possible with a timer, but that gives some complications.
A timer goes through his commands & then waits 100ms before he goes through
his commands again, but if you call sth at the end of the timer, at first
time he goes through it, he won't wait for 100ms.

I found a function on the internet (kernel function: sleep 100), but in that
case, it waited 100 mseconds BEFORE doing anything:
txtInfo.text = "before sleep"
sleep 100
txtInfo2.text = "after sleep"
--> result = that it waits 100 ms and THEN it fills the 2 textboxes, even
the one that stands above the sleep command!

I found a function delay(100) in a dll: port.dll: that is to control the lpt
port, but that dll only works in win98, not in NT or XP. When I use the
function out of that dll, the PC hangs a while & I don't think any code is
executed then...
If anyone knows any command like I need, it would be wonderfull!
I need to write several data to the lpt port & after each command and data
send, has to wait 100ms, so I have to call that function more than once on
different places...

Big thanks in advance!


Jul 17 '05 #1
3 79384
try this. sleep value is miliseconds so 1000 for 1 second.
Public Declare Sub Sleep Lib "kernel32" (ByVal
dwMilliseconds As Long)
Sleep(1000)
"Kuit_been" <nas#at#hotmail.com> wrote in message
news:40**********************@news.skynet.be...
Searched on google, but without any succes.
I need a function where I can define how long the PC has to wait until it
executes its next command.

I know that it is possible with a timer, but that gives some complications. A timer goes through his commands & then waits 100ms before he goes through his commands again, but if you call sth at the end of the timer, at first
time he goes through it, he won't wait for 100ms.

I found a function on the internet (kernel function: sleep 100), but in that case, it waited 100 mseconds BEFORE doing anything:
txtInfo.text = "before sleep"
sleep 100
txtInfo2.text = "after sleep"
--> result = that it waits 100 ms and THEN it fills the 2 textboxes, even
the one that stands above the sleep command!

I found a function delay(100) in a dll: port.dll: that is to control the lpt port, but that dll only works in win98, not in NT or XP. When I use the
function out of that dll, the PC hangs a while & I don't think any code is
executed then...
If anyone knows any command like I need, it would be wonderfull!
I need to write several data to the lpt port & after each command and data
send, has to wait 100ms, so I have to call that function more than once on
different places...

Big thanks in advance!

Jul 17 '05 #2

"Kuit_been" <nas#at#hotmail.com> wrote in message
news:40**********************@news.skynet.be...
I found a function on the internet (kernel function: sleep 100), but in that case, it waited 100 mseconds BEFORE doing anything:
txtInfo.text = "before sleep"
sleep 100
txtInfo2.text = "after sleep"
--> result = that it waits 100 ms and THEN it fills the 2 textboxes, even the one that stands above the sleep command!


The code line before the sleep did execute before the sleep, but the
display update it triggered did not.
You can force the screen update with DoEvents or Refresh:
txtInfo.text = "before sleep"
DoEvents
sleep 100
txtinfo2.text = "after sleep"

Jul 17 '05 #3
On Mon, 8 Mar 2004 17:35:17 +0100, "Kuit_been" <nas#at#hotmail.com>
wrote:
Searched on google, but without any succes.
I need a function where I can define how long the PC has to wait until it
executes its next command.

I know that it is possible with a timer, but that gives some complications.
A timer goes through his commands & then waits 100ms before he goes through
his commands again, but if you call sth at the end of the timer, at first
time he goes through it, he won't wait for 100ms.

I found a function on the internet (kernel function: sleep 100), but in that
case, it waited 100 mseconds BEFORE doing anything:
txtInfo.text = "before sleep"
sleep 100
txtInfo2.text = "after sleep"
--> result = that it waits 100 ms and THEN it fills the 2 textboxes, even
the one that stands above the sleep command!


It is /not/ waiting 100ms before doing anything

txtInfo.text = "before sleep"
That generates a Windows message that will update the contents of
txtInfo
- but only when you let your App process it's message queue
- and since you are ungenerously hogging the current thread's
attention, it cannot process the message queue until you release it.

Try:
txtInfo.text = "before sleep"
DoEvents ' <--- process message queue
sleep 100
txtInfo2.text = "after sleep"

That will behave entirely differently
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
17717
by: CMiYC | last post by:
I'm attempting to open an USB HID device using createfile from kernel32. The open attempt always fails. This is the call I'm using: CreateFile(HidName$, &HC0000000, 3, 0, 3, 0 ,0) HidName$ gets assigned the device: \\?\hid #vid_7766&pid_1629 #6&1b9813bf&0&0000 #{4d1e55b2-f16f-11cf-88cb-00111100030}
14
18804
by: Des L. Davis | last post by:
System: Dell PowerEdge Server with 3 GB RAM, 2.4 GHz Celeron Software: Microsoft SQL Server 2000 Enterprise running on Windows 2003 Server Software: Microsoft SQL Server 2000 Enterprise running on Windows 2000 Server If you run the code below, you'll notice something odd occuring. The MilliSecond value does not change after a 1Millisecond...
1
3374
by: Robert Huie | last post by:
Hi all, I'm trying to use asp.net to code a chat window and I would like to make the http request delay as long as possible till the process/thread detects a new incoming message. basically something like the following: while(nonewmessages) { nonewmessages = checkfornewmessages();
87
4874
by: John Rivers | last post by:
Hello everybody, I just wondered if anybody else has noticed this? It takes around 6 seconds to start debugging a very simple ASPX page with VS.NET whereas VB6 takes under 0.5 seconds, even with very large and complex projects. This is a real shame :(
13
3287
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a referenced, custom dll. I call a PrintImage routine in the dll and pass it only the the Picturebox.hdc from the main form. The dll's print routine...
2
6856
by: yxq | last post by:
Hi VB6 code Picture1.ScaleMode = 0 - User Picture1.ScaleHeight = 100 Picture1.ScaleWidth = 100 The VB.Net code ?
3
7595
by: Standist | last post by:
I use visual studio .net 2003 dim aa as new VB6.FixedLengthString(100) there is a error that VB6.FixedLengthString doesn't a a datatype Should I imports a namespace what it should be?
14
4625
by: Rene Grothmann | last post by:
I have managed to communicate between forms and Java applets. A button press sends the content of the text area to an applet, a second button gets some text from the applet and puts it into the textarea. However, at the start, there is a delay of several seconds, before any of the buttons react to a click. After the first reaction has...
1
3583
by: soms2m | last post by:
HELLO ALL, I want to fill the parent window height with respect to the sub window height which is loading using ajax (mootools). For example if the parent window height is normal and the loading child window height is 1200px (saying), when the child window load the height of the parent window changs but the backgorund color which is given 100%...
0
7270
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...
0
7397
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. ...
0
7565
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...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5103
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...
0
4759
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...
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
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...

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.