Solved

DoEvents in VBScript?

Posted on 2002-05-08
5
3,436 Views
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?
0
Comment
Question by:jeffypop
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 100 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:

<html>
<head>

<script language="VBScript">

Sub counter(lngCnt)
     lngCnt=lngCnt+1
     document.all.CounterDiv.innerHTML=lngCnt
     If lngCnt<100 Then window.setTimeout "counter(" & lngCnt & ")",0
End Sub

</script>

</head>
<body onload="counter(0)">
<div id="CounterDiv"></div>
</body>
</html>
0
 
LVL 1

Expert Comment

by:giladBoker
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(){
  numOfLayer++;
  window.divName.innerText or innerHTML=numOfLayer

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


if(numOfLayer==10){
   clearTimeOut();//stopps the automatic calling
   numOfLayer
}
}
</script>
0
 
LVL 1

Expert Comment

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

Expert Comment

by:gladxml
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

** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **


Just trying to help for the cleanup...
gladxml
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now