BrainDump
  Home arrow BrainDump arrow Page 5 - VBScript: Functions and Loops
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

VBScript: Functions and Loops
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-12-17

    Table of Contents:
  • VBScript: Functions and Loops
  • Sub Procedures
  • Loop Flakes...They're Great!
  • The For Each...Next Loop
  • Do Loop
  • Do Until

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    VBScript: Functions and Loops - Do Loop


    (Page 5 of 6 )

    There are several types of Do Loops. They are all used when you want to execute a block of code, but don't know how many times you will want to do so. Basically, the block of code is repeated while a given condition is true or until that condition becomes true.

    How to Repeat While a Condition is True

    Do While Loop:

    <html>

    <body>

    <script type="text/vbscript">

    i=0

    do while i < 10

    document.write("Beer!" & "<br />")

    i=i+1

    loop

    </script>

    </body>

    </html>

    The above code will continue to loop while the value of "i" is less than 10. Each time through the loop it prints out the delicious word "Beer" and adds one to the counter variable. Note that if the value of "i" had been 9 or greater, the code would never have executed.

    If you wanted to ensure that the code executed AT LEAST once, even if the value of "i" was ten, you could also do this:


    <html>

    <body>

    <script type="text/vbscript">

    i=10

    do

    document.write("Beer!" & "<br />")

    i=i+1

    loop while i < 10

    </script>

    </body>

    </html>

    Which would result in:

      Beer!

    More BrainDump Articles
    More By James Payne


     

    BRAINDUMP ARTICLES

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT