Solved

DoEvents in VBScript?

Posted on 2002-05-08
5
3,462 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP Classic - Load test 2 49
Attaching a file to SMTP in Classic ASP 1 39
Select distinct 25 98
FileUp - Classic ASP 5 16
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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