Trim Function

Here's the branching code again:

UserName = Trim(UserName)
If UserName = "" Then
Greeting = "Why won't you tell me you name? That's not very nice."
Greeting = "Hello, " & UserName & ", it's a pleasure to meet you."
End If

We use the Trim () function here to further insulate our script from unpredictability. The Trim () function takes any kind of text as a parameter, and returns the same text, but with any leading or trailing spaces removed. For example, the text "Hello" passed to the Trim () function would come back as just "Hello". We do this just in case the user enters a sequence of one or more spaces, which, for the purpose of our script, is equivalent to not having entered anything. Also notice the double quotation marks (" ") in the line IF Trim (UserName) = "" Then. This is the way to express the "Zero-Length string" that I talked about earlier.