VBScript: Functions and Loops - Do Until
(Page 6 of 6 )
If you wanted to execute some code until a certain condition became true, you could use the Until Keyword, like so:
<html>
<body>
<script type="text/vbscript">
i=1
do Until i=10
document.write("Beer!" & "<br />")
i=i+1
Loop
</script>
</body>
</html>
Again the result:
Beer!
Beer!
Beer!
Beer!
Beer!
Beer!
Beer!
Beer!
Beer!
And we can, of course, force this code to execute AT LEAST once as well:
<html>
<body>
<script type="text/vbscript">
i=10
do
document.write("Beer!" & "<br />")
i=i+1
Loop until i=10
</script>
</body>
</html>
Since the value begins at 10, here is the result:
Beer!
While that isn't everything there is to know about loops and functions, it is a good start, and I am currently all out of time. My next VBScript tutorial will discuss some of the different types of functions in VBScript, like array and date functions, and go more in-depth on how to use them. So check back often.
Till then...
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |