Formatting Text With RTF Codes
You can format the text shown by the WinInputBox and WinMsgBox functions using a limited set of Rich Text Format (RTF) codes within the text. Many of the codes use the plus symbol (+) and minus symbol (-) to enclose the text that they affect. The codes are only evaluated for the Prompt argument of the functions and do not work in the Title argument text.
The following table describes the available codes.
Code | Description |
---|---|
$RTF+/- |
Enable or disable formatting |
$NL |
Inserts a new line |
$CENTER+ |
Center justification |
$RIGHT+ |
Right justification |
$RESET |
Reset text justification (left justification) |
$NUM+/- |
Numbered list |
$B+/- |
|
$I+/- |
Italic attribute |
$U+/- |
Underline attribute |
$UT+/- |
Thick underline attribute |
$UDOT+/- |
Dot underline attribute |
$UD+/- |
Dash underline attribute |
$UDD+/- |
Dot dash underline attribute |
$UDDD+/- |
Dot dot dash underline attribute |
$UW+/- |
Wavey underline attribute |
$STR+/- |
Strikethrough attribute |
$SUB+/- |
Subscript attribute |
$SUP+/- |
Superscript attribute |
$CAPS+/- |
All capitals attribute |
$BULLET+/- |
Bullet list |
$BLACK+/- |
Black color attribute |
$BLUE+/- |
Blue color attribute |
$CYAN+/- |
Cyan color attribute |
$GREEN+/- |
Green color attribute |
$MAGENTA+/- |
Magenta color attribute |
$RED+/- |
Red color attribute |
$YELLOW+/- |
Yellow color attribute |
$WHITE+/- |
White color attribute |
$DBLUE+/- |
Dark blue color attribute |
$DCYAN+/- |
Dark cyan color attribute |
$DGREEN+/- |
Dark green color attribute |
$DMAGENTA+/- |
Dark magenta color attribute |
$DRED+/- |
Dark red color attribute |
$DYELLOW+/- |
Dark yellow color attribute |
$DGRAY+/- |
Dark gray color attribute |
$GRAY+/- |
Gray color attribute |
$AUTO |
Automatic color attribute |
$B_<ColorName>+/- |
Background color attribute where <ColorName> is one of the colors listed above. |
The following example VBScript code incorporates several formatting codes to produce the result shown in the following figure.
WinMsgBox "$RTF+Read each item in the following bulleted list carefully:$NL" & _
"$BULLET+This is $B+bold$B- text.$NL" & _
"This is $I+italic$I- text.$NL" & _
"This is $U+underlined$U- text.$NL" & _
$BULLET-$NLWas this example helpful?$RTF-", _
AS_QUESTION Or AS_YESNO, _
"Formatted Text Example"