@WikiNewPageEditViewToolsHelp
Create New Page Create New Page from Copy
Create your new wiki
Edit this page Copy from this page Rename
Attach (Upload) File
Edit Menu
Newest Change History Referer Trackback
Page List Tag Cloud RSS1.0 RSS2.0
Search
@Wiki Guide
FAQ/about @wiki FAQ/about Editting FAQ/about Register
Update Infomation Release Plan

Learn VB Script

Added line is this color

Deleted line is this color

 
 <h2> What is VBScript?</h2>
 <ul>
 <li>VBScript is a scripting language</li>
 <li>A scripting language is a lightweight programming language</li>
 <li>VBScript is a light version of Microsoft's programming language Visual
 Basic</li>
 </ul>
 <h2>How Does it Work?</h2>
 <p>When a VBScript is inserted into a HTML document, the Internet browser will
 read the HTML and interpret the VBScript. The VBScript can be executed
 immediately, or at a later event.</p>
 <h2>How to Put VBScript Code in an HTML Document</h2>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 &lt;html&gt;
 &lt;head&gt;
 &lt;/head&gt;
 &lt;body&gt;
 </pre>
 <pre>
 <span class="blue">&lt;script type="text/vbscript"&gt;</span>
 <span class="red">document.write("Hello from VBScript!")
 </span><span class="blue">&lt;/script&gt;</span>
 </pre>
 <pre>
 &lt;/body&gt;
 &lt;/html&gt;
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>And it produces this output:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>Hello from VBScript!</td>
 </tr>
 </tbody>
 </table>
 <p>To insert a script in an HTML document, use the &lt;script&gt; tag. Use the
 type attribute to define the scripting language.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 <span class="blue">&lt;script type="text/vbscript"&gt;</span>
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>Then comes the VBScript: The command for writing some text on a page is
 <strong>document.write</strong>: </p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 <span class="red">document.write("Hello from VBScript!")</span>
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The script ends:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 <span class="blue">&lt;/script&gt;</span>
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p> </p>
 <hr>
 <h2>How to Handle Older Browsers</h2>
 <p>Older browsers that do not support scripts will display the script as page
 content. To prevent them from doing this, you can use the HTML comment tag:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 <span class="blue">&lt;script type="text/vbscript"&gt;
 &lt;!--</span>
   some statements
 <span class="blue">--&gt;
 &lt;/script&gt;</span>
 </pre></td>
 </tr>
 </tbody>
 </table>
 <h2>Examples</h2>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_headsection"
 target="_blank"><u><font color="#0000FF">Head section</font></u></a><br>
 Scripts can be placed in the head section. Usually we put all the "functions"
 in the head section. The reason for this is to be sure that the script is
 loaded before the function is called.</p>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_bodysection"
 target="_blank"><u><font color="#0000FF">Body section</font></u></a><br>
 Execute a script that is placed in the body section. Scripts in the body
 section are executed when the page is loading.</p>
 <hr>
 <h2>Where to Put the VBScript</h2>
 <p>Scripts in a page will be executed immediately while the page loads into the
 browser. This is not always what we want. Sometimes we want to execute a script
 when a page loads, other times when a user triggers an event.</p>
 <p><strong>Scripts in the head section:</strong> Scripts to be executed when
 they are called or when an event is triggered go in the head section. When you
 place a script in the head section you will assure that the script is loaded
 before anyone uses it:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 &lt;html&gt;
 &lt;head&gt;
 <span class="blue">&lt;script type="text/vbscript"&gt;</span>
   some statements<span class="blue">
 &lt;/script&gt;</span>
 &lt;/head&gt;
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p><strong>Scripts in the body section:</strong> Scripts to be executed when
 the page loads go in the body section. When you place a script in the body
 section it generates the content of the page:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 &lt;html&gt;
 &lt;head&gt;
 &lt;/head&gt;
 &lt;body&gt;
 <span class="blue">&lt;script type="text/vbscript"&gt;</span>
   some statements<span class="blue">
 &lt;/script&gt;</span>
 &lt;/body&gt;
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p><strong>Scripts in both the body and the head section:</strong> You can
 place an unlimited number of scripts in your document, so you can have scripts
 in both the body and the head section.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 &lt;html&gt;
 &lt;head&gt;
 <span class="blue">&lt;script type="text/vbscript"&gt;</span>
   some statements<span class="blue">
 &lt;/script&gt;</span>
 &lt;/head&gt;
 &lt;body&gt;
 <span class="blue">&lt;script type="text/vbscript"&gt;</span>
   some statements<span class="blue">
 &lt;/script&gt;</span>
 &lt;/body&gt;
 </pre></td>
 </tr>
 </tbody>
 </table>
 <h2>Examples</h2>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_variable" target=
 "_blank"><u><font color="#0000FF">Create a variable</font></u></a><br>
 Variables are used to store information. This example demonstrates how you can
 create a variable, and assign a value to it.</p>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_variable2" target=
 "_blank"><u><font color="#0000FF">Insert a variable value in a
 text</font></u></a><br>
 This example demonstrates how you can insert a variable value in a text.</p>
 <p><a href="http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_array"
 target="_blank"><u><font color="#0000FF">Create an array</font></u></a><br>
 Arrays are used to store a series of related data items. This example
 demonstrates how you can make an array that stores names. ( We are using a "for
 loop" to demonstrate how you write the names. )</p>
 <hr>
 <h2>What is a Variable?</h2>
 <p>A variable is a "container" for information you want to store. A variable's
 value can change during the script. You can refer to a variable by name to see
 its value or to change its value. In VBScript, all variables are of type
 <em>variant</em>, that can store different types of data. </p>
 <hr>
 <h2>Rules for Variable Names:</h2>
 <ul>
 <li>Must begin with a letter </li>
 <li>Cannot contain a period (.)</li>
 <li>Cannot exceed 255 characters</li>
 </ul>
 <hr>
 <h2>Declaring Variables</h2>
 <p>You can declare variables with the Dim, Public or the Private statement.
 Like this: </p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 dim name
 name=some value
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>Now you have created a variable. The name of the variable is "name".</p>
 <p>You can also declare variables by using its name in your script. Like
 this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 name=some value
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>Now you have also created a variable. The name of the variable is
 "name".</p>
 <p>However, the last method is not a good practice, because you can misspell
 the variable name later in your script, and that can cause strange results when
 your script is running. This is because when you misspell for example the
 "name" variable to "nime" the script will automatically create a new variable
 called "nime".  To prevent your script from doing this you can use the Option
 Explicit statement. When you use this statement you will have to declare all
 your variables with the dim, public or private statement. Put the Option
 Explicit statement on the top of your script. Like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 option explicit
 dim name
 name=some value
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p> </p>
 <hr>
 <h2>Assigning Values to Variables</h2>
 <p>You assign a value to a variable like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 name="Hege"
 i=200
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The variable name is on the left side of the expression and the value you
 want to assign to the variable is on the right. Now the variable "name" has the
 value "Hege".</p>
 <hr>
 <h2>Lifetime of Variables</h2>
 <p>How long a variable exists is its lifetime.<br>
 <br>
 When you declare a variable within a procedure, the variable can only be
 accessed within that procedure. When the procedure exits, the variable is
 destroyed. These variables are called local variables. You can have local
 variables with the same name in different procedures, because each is
 recognized only by the procedure in which it is declared.<br>
 <br>
 If you declare a variable outside a procedure, all the procedures on your page
 can access it. The lifetime of these variables starts when they are declared,
 and ends when the page is closed.</p>
 <hr>
 <h2>Array Variables</h2>
 <p>Sometimes you want to assign more than one value to a single variable. Then
 you can create a variable that can contain a series of values. This is called
 an array variable. The declaration of an array variable uses parentheses ( )
 following the variable name. In the following example, an array containing 3
 elements is declared:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 dim names(2)
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The number shown in the parentheses is 2. We start at zero so this array
 contains 3 elements. This is a fixed-size array. You assign data to each of the
 elements of the array like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 names(0)="Tove"
 names(1)="Jani"
 names(2)="Stale"
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>Similarly, the data can be retrieved from any element using the index of the
 particular array element you want. Like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 mother=names(0)
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>You can have up to 60 dimensions in an array. Multiple dimensions are
 declared by separating the numbers in the parentheses with commas. Here we have
 a two-dimensional array consisting of 5 rows and 7 columns:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 dim table(4, 6)
 </pre></td>
 </tr>
 </tbody>
 </table>
 <h2>Examples</h2>
 <p><a href="http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_sub"
 target="_blank"><u><font color="#0000FF">Sub procedure</font></u></a><br>
 The sub procedure does not return a value.</p>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_function" target=
 "_blank"><u><font color="#0000FF">Function procedure</font></u></a><br>
 The function procedure is used if you want to return a value.</p>
 <hr>
 <h2>VBScript Procedures</h2>
 <p>We have two kinds of procedures: The Sub procedure and the Function
 procedure.</p>
 <p>A Sub procedure:</p>
 <ul>
 <li>is a series of statements, enclosed by the Sub and End Sub statements</li>
 <li>can perform actions, but <strong>does not return</strong> a value</li>
 <li>can take arguments that are passed to it by a calling procedure</li>
 <li>without arguments, must include an empty set of parentheses ()</li>
 </ul>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Sub mysub()
  some statements
 End Sub
 </pre>
 <p>or</p>
 <pre>
 Sub mysub(argument1,argument2)
  some statements<em>
 </em>End Sub
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>A Function procedure:</p>
 <ul>
 <li>is a series of statements, enclosed by the Function and End Function
 statements</li>
 <li>can perform actions and <strong>can return</strong> a value</li>
 <li>can take arguments that are passed to it by a calling procedure</li>
 <li>without arguments, must include an empty set of parentheses ()</li>
 <li>returns a value by assigning a value to its name</li>
 </ul>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Function myfunction()
  some statements
 <em> </em>myfunction=some value
 End Function
 </pre>
 <p>or</p>
 <pre>
 Function myfunction(argument1,argument2)
  some statements
 <em> </em>myfunction=some value
 End Function
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p> </p>
 <hr>
 <h2>Call a Sub or Function Procedure</h2>
 <p>When you call a Function in your code, you do like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 name = findname()
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>Here you call a Function called "findname", the Function returns a value
 that will be stored in the variable "name".</p>
 <p>Or, you can do like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 msgbox "Your name is " &amp; findname()
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>Here you also call a Function called "findname", the Function returns a
 value that will be displayed in the message box.</p>
 <p>When you call a Sub procedure you can use the Call statement, like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Call MyProc(argument)
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>Or, you can omit the Call statement, like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 MyProc argument
 </pre></td>
 </tr>
 </tbody>
 </table>
 <h2>Examples</h2>
 <p><a href="http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_ifthen"
 target="_blank"><u><font color="#0000FF">The if...then...else
 statement</font></u></a><br>
 This example demonstrates how to write the if...then..else statement.</p>
 <p><a href="http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_elseif"
 target="_blank"><u><font color="#0000FF">The if...then...elseif...
 statement</font></u></a><br>
 This example demonstrates how to write the if...then...elseif statement.</p>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_selectcase"
 target="_blank"><u><font color="#0000FF">The select case
 statement</font></u></a><br>
 This example demonstrates how to write the select case statement.</p>
 <hr>
 <h2>Conditional Statements</h2>
 <p>Very often when you write code, you want to perform different actions for
 different decisions. You can use conditional statements in your code to do
 this.</p>
 <p>In VBScript we have three conditional statements:</p>
 <ul>
 <li><strong>if statement</strong> - use this statement if you want to execute a
 set of code when a condition is true</li>
 <li><strong>if...then...else statement</strong> - use this statement if you
 want to select one of two sets of lines to execute</li>
 <li><strong>if...then...elseif statement</strong> - use this statement if you
 want to select one of many sets of lines to execute</li>
 <li><strong>select case statement</strong> - use this statement if you want to
 select one of many sets of lines to execute</li>
 </ul>
 <hr>
 <h2>If....Then.....Else</h2>
 <p>You should use the If...Then...Else statement if you want to</p>
 <ul>
 <li>execute some code if a condition is true</li>
 <li>select one of two blocks of code to execute</li>
 </ul>
 <p>If you want to execute only <strong>one</strong> statement when a condition
 is true, you can write the code on one line:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 if i=10 Then msgbox "Hello"
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>There is no ..else.. in this syntax. You just tell the code to perform
 <strong>one action</strong> if the condition is true (in this case if
 i=10).</p>
 <p>If you want to execute <strong>more than one</strong> statement when a
 condition is true, you must put each statement on separate lines and end the
 statement with the keyword "End If":</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 if i=10 Then
    msgbox "Hello"
    i = i+1
 end If
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>There is no ..else.. in this syntax either. You just tell the code to
 perform <strong>multiple actions</strong> if the condition is true.</p>
 <p>If you want to execute a statement if a condition is true and execute
 another statement if the condition is not true, you must add the "Else"
 keyword:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 if i=10 then
    msgbox "Hello"
 else
    msgbox "Goodbye"
 end If
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The first block of code will be executed if the condition is true, and the
 other block will be executed otherwise (if i is not equal to 10).</p>
 <hr>
 <h2>If....Then.....Elseif</h2>
 <p>You can use the if...then...elseif statement if you want to select one of
 many blocks of code to execute:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 if payment="Cash" then
    msgbox "You are going to pay cash!"
  elseif payment="Visa" then
    msgbox "You are going to pay with visa."
  elseif payment="AmEx" then
    msgbox "You are going to pay with American Express."
  else
    msgbox "Unknown method of payment."
 end If
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p> </p>
 <hr>
 <h2>Select Case</h2>
 <p>You can also use the SELECT statement if you want to select one of many
 blocks of code to execute:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 select case payment
  case "Cash"
    msgbox "You are going to pay cash"
  case "Visa"
    msgbox "You are going to pay with visa"
  case "AmEx"
    msgbox "You are going to pay with American Express"
  case Else
    msgbox "Unknown method of payment"
 end select
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>This is how it works: First we have a single expression (most often a
 variable), that is evaluated once. The value of the expression is then compared
 with the values for each Case in the structure. If there is a match, the block
 of code associated with that Case is executed.</p>
 <h2>Examples</h2>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_fornext" target=
 "_blank"><u><font color="#0000FF">For...next loop</font></u></a><br>
 This example demonstrates how to make a simple <strong>For....Next</strong>
 loop.</p>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_fornext2" target=
 "_blank"><u><font color="#0000FF">Looping through headers</font></u></a><br>
 This example demonstrates how you can loop through the 6 headers in html.</p>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_foreach" target=
 "_blank"><u><font color="#0000FF">For...each loop</font></u></a><br>
 This example demonstrates how to make a simple <strong>For.....Each</strong>
 loop.</p>
 <p><a href=
 "http://www.w3schools.com/vbscript/tryit.asp?filename=vbdemo_dowhile" target=
 "_blank"><u><font color="#0000FF">Do...While loop</font></u></a><br>
 This example demonstrates how to make a simple <strong>Do...While</strong>
 loop.</p>
 <hr>
 <h2>Looping Statements</h2>
 <p>Very often when you write code, you want to allow the same block of code to
 run a number of times. You can use looping statements in your code to do
 this.</p>
 <p>In VBScript we have four looping statements:</p>
 <ul>
 <li><strong>For...Next statement</strong> - runs statements a specified number
 of times. </li>
 <li><strong>For Each...Next statement</strong> - runs statements for each item
 in a collection or each element of an array</li>
 <li><strong>Do...Loop statement</strong> - loops while or until a condition is
 true</li>
 <li><strong>While...Wend statement</strong> - Do not use it - use the Do...Loop
 statement instead</li>
 </ul>
 <hr>
 <h2>For...Next Loop</h2>
 <p>You can use a <strong>For...Next</strong> statement to run a block of code,
 when you know how many repetitions you want.</p>
 <p>You can use a counter variable that increases or decreases with each
 repetition of the loop, like this:</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 For i=1 to 10
   some code
 Next
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The <strong>For</strong> statement specifies the counter variable
 (<strong>i</strong>) and its start and end values. The <strong>Next</strong>
 statement increases the counter variable (<strong>i</strong>) by one.</p>
 <h3>Step Keyword</h3>
 <p>Using the <strong>Step</strong> keyword, you can increase or decrease the
 counter variable by the value you specify.</p>
 <p>In the example below, the counter variable (<strong>i</strong>) is increased
 by two each time the loop repeats.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 For i=2 To 10 Step 2
   some code
 Next
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>To decrease the counter variable, you must use a negative
 <strong>Step</strong> value. You must specify an end value that is less than
 the start value.</p>
 <p>In the example below, the counter variable (<strong>i</strong>) is decreased
 by two each time the loop repeats.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 For i=10 To 2 Step -2
   some code
 Next
 </pre></td>
 </tr>
 </tbody>
 </table>
 <h3>Exit a For...Next</h3>
 <p>You can exit a For...Next statement with the Exit For keyword.</p>
 <hr>
 <h2>For Each...Next Loop</h2>
 <p>A <strong>For Each...Next</strong> loop repeats a block of code for each
 item in a collection, or for each element of an array.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 dim cars(2)
 cars(0)="Volvo"
 cars(1)="Saab"
 cars(2)="BMW"
 
 For Each x in cars
   document.write(x &amp; "&lt;br /&gt;")
 Next
 </pre></td>
 </tr>
 </tbody>
 </table>
 <hr>
 <h2>Do...Loop</h2>
 <p>You can use Do...Loop statements to run a block of code when you do not know
 how many repetitions you want. The block of code is repeated while a condition
 is true or until a condition becomes true.</p>
 <h3>Repeating Code While a Condition is True</h3>
 <p>You use the While keyword to check a condition in a Do...Loop statement.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Do While i&gt;10
   some code
 Loop
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>If <strong>i</strong> equals 9, the code inside the loop above will never be
 executed.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Do
   some code
 Loop While i&gt;10
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The code inside this loop will be executed at least one time, even if
 <strong>i</strong> is less than 10.</p>
 <h3>Repeating Code Until a Condition Becomes True</h3>
 <p>You use the Until keyword to check a condition in a Do...Loop statement.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Do Until i=10
   some code     
 Loop
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>If <strong>i</strong> equals 10, the code inside the loop will never be
 executed.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Do
   some code
 Loop Until i=10
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The code inside this loop will be executed at least one time, even if
 <strong>i</strong> is equal to 10.</p>
 <h3>Exit a Do...Loop</h3>
 <p>You can exit a Do...Loop statement with the Exit Do keyword.</p>
 <table class="ex" cellspacing="0" width="100%" border="1">
 <tbody>
 <tr>
 <td>
 <pre>
 Do Until i=10
   i=i-1
   If i&lt;10 Then Exit Do
 Loop
 </pre></td>
 </tr>
 </tbody>
 </table>
 <p>The code inside this loop will be executed as long as <strong>i</strong> is
 different from 10, and as long as <strong>i</strong> is greater than 10.</p>
 <h2>VBScript Summary</h2>
 <p>This tutorial has taught you how to add VBScript to your HTML pages, to make
 your web site more dynamic and interactive.</p>
 <p>You have learned how to create variables and functions, and how to make
 different scripts run in response to different scenarios.</p>
 <p>For more information on VBScript, please look at our <a href=
 "http://www.w3schools.com/vbscript/vbscript_examples.asp"><u><font color=
 "#800080">VBScript examples</font></u></a> and our <a href=
 "http://www.w3schools.com/vbscript/vbscript_ref_functions.asp"><u><font color=
 "#0000FF">VBScript references</font></u></a>.</p>
 <hr>
 <h2>Now You Know VBScript, What's Next?</h2>
 <p>The next step is to learn ASP.</p>
 <p>While scripts in an HTML file are executed on the client (in the browser),
 scripts in an ASP file are executed on the server.</p>
 <p>With ASP you can dynamically edit, change or add any content of a Web page,
 respond to data submitted from HTML forms, access any data or databases and
 return the results to a browser, customize a Web page to make it more useful
 for individual users.</p>