Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2008, 11:34 PM
Registered User
 
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How Can I Pause Loop

Is there a way to add a pause before a loop loops? For example:

for i=0 to 10

i=i+1

'pause for 10 seconds

next



 
Old July 17th, 2008, 11:56 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

You can try using sleep API function (

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

for i=0 to 10

i=i+1

'pause for 10 seconds
Sleep 10000 ' sleep is in milliseconds

next


) or use Application.Wait if it is Excel VBA (http://vbadud.blogspot.com/2008/03/s...excel-vba.html)

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old July 18th, 2008, 08:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. is there a point in trying to slowing the for...next??

Sleep is the perfect solution, but take in mind that if you sleep the thread, if will not receive even buttons events, so your program will look like frozen for about 100 seconds...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old July 18th, 2008, 10:55 AM
Registered User
 
Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This loop is in a .vbs script that is executed from the server using Taks Manager every min. Would the sleep function just affect the .vbs script or would it affect live websites on the server? Also, is it possible to have multiple instances of a .vbs script running? For ex, the script basically does this:

check database
if new user is true

for i=0 to 1000000

do something
i=i+1
sleep for 10 sec
next
end if

Every minute it should run and check to see if a new user has signed up and if so, run through the series of functions specifically for that user. These functions could take an extremely long time (days) to finish. If Task Manager is executing the vbs file every minute, is it executing a new instance or would it just ignore the request because it will see it as already running? Hope that makes sense. Also, how would the sleep function affect the program in this scenario?

Thanks for the help!

 
Old July 18th, 2008, 11:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I don't think this is the best way to do this.. probably just a program (something like in vb 6)

I don't know what thing task manager do with a script, also I don't understand (me, maybe I lack that kind of info), how to run a script if you are not calling a page in the server.

IMHO, this is by far the worst solution to this...



HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old July 18th, 2008, 01:01 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

How are new users sighing up? I think there may be a better way to respond to that happening, but I need to know the method that is allowing them to sign up.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pause between macros paul20091968 Access VBA 2 April 6th, 2007 01:40 AM
Pause Code stealthdevil Access VBA 5 February 5th, 2007 12:48 PM
"Pause" Checking ... tonyrosen Excel VBA 2 November 23rd, 2005 11:02 AM
Pause Printing rajanikrishna Pro VB 6 0 November 28th, 2004 09:13 PM
Add a Pause snowy0 VB.NET 2002/2003 Basics 3 February 1st, 2004 12:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.