String Data Literals
This section provides rules on writing String data literals, characters enclosed in double quotes.
In the previous section, we learned that a String data literal is a sequence of characters enclosed in double quotes ("), like "Hello".
But there is one additional rule about String data literals:
- If a double quote (") is part of the string, the double quote needs to be prefixed with another double quote as ("").
I have the following script, string_literal.html, to show you how to include double quotes in string literals:
- Copyright (c) 2015, HerongYang.com, All Rights Reserved.
document.writeln("He said: ""Hello?""")
document.writeln("She said: ""Hello, Who's calling?""")
Here is the output of the sample script:
He said: "Hello?"
She said: "Hello, Who's calling?"
By the way, VBScript does not support string literals with single quotes (').
Table of Contents
About This Book
Introduction of VBScript - Visual Basic Scripting Edition
►Variant Data Type, Subtypes, and Literals
"Variant" - Data Type and Subtypes
Data Literal Examples
►String Data Literals
Date and Time Data Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
Creating Your Own Classes
IE Web Browser Supporting VBScript
IIS ASP Server Supporting VBScript
WSH (Windows Script Host)
PDF Printing Version