MsgBox Function in Fourth Line

Dim DateToday
'Initialize the variable
DateToday = Date
MsgBox "Today's date is " &DateToday & "."

In line four, now that we've initialized this variable, we're going to do something useful with it. MsgBox is anther built-in VBScript function. Some functions, such as the Date function, do not require you to pass parameters to them. This is because the Date function does not need any additional information from you in order to do its job. All it needs to know how to do is read the computer's clck and return the current date. The MsgBox function, on the other hand, displays a piece of information to the user in the form of a dialog box.

You have to pass MsgBox a parameter - otherwise, it would not have anything to display. The MsgBox function actually has several parameters, but we only used the first one. This is because the returning parameters are optional parameters. You probably also noticed the ampersand (&) symbol in line four. The ampersand is a VBScript operator, and is used to concatenate text together. To concatenate means to "string together." This text can either take the form of a literal, or a variable. A literal is the opposite of variable: a variable is so named because it can change throughout the lifetime of the script. Unlike a variable, a literal cannot change during the lifetime of the script. Here is line four of the script again:

MsgBox "Today's date is " &DateToday & "."

The part in bold are the literals. Notice how the concatenation of the DateToday variable results in the text "Today's date is 18/8/2008". in the resulting dialogue box.

First
Next