Microsoft Visual Basic Script (VBS) language allows users to add additional functions to their Window applications. It also gives you the ability to loop the execution of VBS script when you need to run a group of VBS statements repeatedly. You can repeat the statements until a condition is true or false or repeat statements a specific number of times. The loop statements in VBS scripts help you to add additional options to Windows applications.
Click "Start' in Windows followed by "Microsoft Visual Basic Script Editor."
Enter the following code in the open window:
Dim counter, myNum
counter = 0
myNum = 20
Do While myNum > 10
myNum = myNum - 1
counter = counter + 1
MsgBox "The loop made ' & counter & ' repetitions."
For x = 1 To 50
MsgBox "The loop repeats 50 times."
Dim d 'Create a variable
Set d = CreateObject("Scripting.Dictionary")
d.Add "0", "Greece" 'Add some keys and items
d.Add "1", "France"
d.Add "2", "Spain"
For Each I in d
Document.frmForm.Elements(I).Value = D.Item(I)
MsgBox "The loop repeats ' & d & ' times."
Click "File" followed by "Save' to apply the code VBS script in your application.
- Photo Credit Comstock/Comstock/Getty Images
How Execute VBS Script
A VBS script is a file that contains VBScript or Visual Basic Scripting codes. You can examine the script's contents by opening...
VBS Scripts Won't Run
All versions of Windows starting from Windows 95 are capable of running VBS files. VBS or VBScript files contain Visual Basic code...