DoEvents in VBScript?

Posted on 2002-05-08
Medium Priority
Last Modified: 2008-02-07
I am running through a client side loop on an asp page. During each pass in this loop, I want to change the innerText of a div on the page. Trouble is, the text in the div never changes until the sub is complete, and the div text is whatever the loop last set it to. I know DoEvents is not included in VBScript, but that's the functionality I need. Does anyone know of something that achieves what DoEvents achieves? How can I get the page to display the changes I make while the sub is still executing?
Question by:jeffypop
  • 2
LVL 29

Accepted Solution

Göran Andersson earned 400 total points
ID: 6996917
Hm... this is not an ASP question at all...

Well, anyway, to make the display update, you have to end the script. To start a script automatically again to continue the loop, you add a timeout to the window object, with the delay of zero milliseconds.

This of course means that you have to code your loop somewhat differently. It has to be in a form of a sub that calls itself.

I made a small example, that loops from 1 to 100:


<script language="VBScript">

Sub counter(lngCnt)
     If lngCnt<100 Then window.setTimeout "counter(" & lngCnt & ")",0
End Sub


<body onload="counter(0)">
<div id="CounterDiv"></div>

Expert Comment

ID: 6998314
u can use the client side for it to.

if u use javascript like that.

<script language=javascript>
var numOfLayer=0;
function ChangeDiv(){
  window.divName.innerText or innerHTML=numOfLayer

  setTimeOut('ChangeDiv()',500);//this reloads the function again every 500 mili seconds

   clearTimeOut();//stopps the automatic calling

Expert Comment

ID: 6998317
Sorry my answer is like greenGhost but just in javascript
LVL 15

Expert Comment

ID: 8803107
No comment has been added lately and it seems that this question have been abandoned. So it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question or invite a Moderator to close this question if there's no reply from you after seven days.

In the absence of responses, I will recommend the following:

To accept the comment and points awarded to GreenGhost


Just trying to help for the cleanup...

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question