Input in Do...Loop Code

Dim Greeting
Dim UserName
Dim TryAgain
Do
TryAgain = "No"
UserName = "InputBox("Please enter your name:")
If Trim(UserName) = " " Then
MsgBox "You must enter your name."
TryAgain = "Yes"
Else
Greeting = "Hello. " & UserName & ", it's a pleasure to meet you."
End If
Loop While TryAgain = "Yes"
MsgBox Greeting

Do
TryAgain = "No"
UserName = "InputBox("Please enter your name:")

This should look familiar. We are using the InputBox function to ask the user for their name. We store the return value from the function in the UserName variable. Whatever the user types in, if anything, will be stored in this variable. Put another way, our script is receiving some external input - and remember that I said input is always unpredictable.

First
Next