Solved

DoEvents in VBScript?

Posted on 2002-05-08
5
3,490 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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