VBScript Basics, Part 7 | Do Loops


VBScripting (.vbs) Basic tutorial on how to use a Do Loop. Either until something is true or while it is. Also, how to exit out of never ending scripts. And how to create a password input.

Code Example:
______________________________________________________

Option Explicit
Dim a
a=0

Do until a=5
a=a+1
msgbox a
Loop
______________________________________________________

Option Explicit
Dim pass

pass=InputBox(vbLf&vbLf&vbLf&vbLf&vbLf & “Enter your password…” ,”Verification:”)
Do
If pass=”wired” Then
Exit Do
ElseIf pass=”” Then
pass=InputBox(“Do not leave field blank.” &vbLf&vbLf&vbLf&vbLf&vbLf & “Enter your password…” ,”Verification:”)
ElseIf Not pass=”wired” Then
pass=InputBox(“Incorrect: Try Again.”&vbLf&vbLf&vbLf&vbLf&vbLf & “Enter your password…” ,”Verification:”)
End If
Loop

msgbox “Correct”,vbInformation ,”Verification:”
______________________________________________________

Know the Basics:
——————————————————————————————
Do until/while condition
‘code here
Loop
——————————————————————————————

Leave a Comment