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.
- Skill level:
Other People Are Reading
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.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for