VBScript Tutorials - Herong's Tutorial Examples - Version 5.20, by Dr. Herong Yang

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:

<html>
<body>
<!-- string_literal.html
 - Copyright (c) 2015, HerongYang.com, All Rights Reserved.
-->
<pre>
<script language="vbscript">
   document.writeln("Ding...")
   document.writeln("He said: ""Hello?""")
   document.writeln("She said: ""Hello, Who's calling?""")
</script>
</pre>
</body>
</html>

Here is the output of the sample script:

Ding...
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 Literals

 Data Literal Examples

String Data Literals

 Date and Time Data Literals

 Arithmetic Operations

 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

 Built-in Functions

 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)

 References

 Printable Copy - PDF Version

String Data Literals - Updated in 2015, by Dr. Herong Yang