Print Double Quotes in Classic ASP (VBScript)

To print a quotation mark (") in Classic ASP, double it inside a VBScript string or use Chr(34). Both methods work with Response.Write.

Quick example: place two double quotes inside a quoted string.

Response.Write "Raju told ""ASP is a better scripting language"""

Output: Raju told "ASP is a better scripting language"

Three ways to display double quotes ↑

VBScript uses double quotes to delimit string values. To include a quotation mark inside a quoted string, write it twice. Alternatively, generate the character using Chr(34). The HTML entity " is useful when writing HTML, but it is not a replacement for VBScript string quoting.

MethodWhen to useResult
Two quotes inside a stringMost VBScript text examplesOne visible "
Chr(34)Joining text and quote charactersOne visible "
"Generating HTML textQuotation mark displayed by the browser

Print a double quote using Chr(34) ↑

The character code 34 represents a double quotation mark. It can be printed directly or stored in a variable for repeated use.

Print one double quotation mark.

Response.Write Chr(34)

Output: "

Build a sentence by concatenating a quotation-mark character.

Dim quoteChar, sentence
quoteChar = Chr(34)
sentence = "She said " & quoteChar & "Hello!" & quoteChar
Response.Write sentence

Output: She said "Hello!"

See joining strings using the ampersand operator for more concatenation examples.

Print quotes by doubling them inside strings ↑

Within a VBScript quoted string, "" represents one literal double quote. To print a double quote by itself, use a string literal made of four quote characters: an opening delimiter, two quotes for the character, and a closing delimiter.

Four double-quote characters produce one visible quotation mark.

Response.Write """"

Output: "

Include quoted words in the middle of a sentence.

Dim message
message = "Raju told ""ASP is a better scripting language"""
Response.Write message

Output: Raju told "ASP is a better scripting language"

Use doubled quotation marks more than once.

Dim message
message = "He said ""Hello"", and I replied ""Welcome""."
Response.Write message

Output: He said "Hello", and I replied "Welcome".

Quote characters are not backslash-escaped

In VBScript, the backslash is not a general string-escape character. Do not use \" in place of doubled quotes. Also, a single quote (') outside a string begins a VBScript comment.

Use quotes when generating HTML with Response.Write ↑

HTML attributes commonly use quotation marks. When the entire HTML tag is inside a VBScript string, double each embedded attribute quote so the generated HTML remains valid.

Write HTML containing a quoted class attribute.

Response.Write "<p class=""text-success"">Welcome to Plus2Net</p>"

HTML sent to the browser:

<p class="text-success">Welcome to Plus2Net</p>

Another option for displaying a quote as text in HTML is &quot;. The browser decodes the entity into a visible quotation mark.

The HTML entity is inside an ordinary VBScript string.

Response.Write "&quot;Learn Classic ASP&quot;"

Displayed output: "Learn Classic ASP"

Important: doubling quotation marks is a VBScript string-literal rule; &quot; is an HTML entity. They are used at different stages of creating the page.

Display a session value in an HTML table ↑

To display the value of a session variable, read Session("userid") outside the quoted HTML string. Writing the expression entirely inside double quotes prints it as ordinary text instead.

Complete Classic ASP snippet showing the session value in a table.

<%
Dim userId
Session("userid") = "student42"  ' Example value for this tutorial
userId = Session("userid")
Response.Write "<table class=""table table-bordered"">"
Response.Write "<tr><th>User ID</th><td>" & Server.HTMLEncode(CStr(userId)) & "</td></tr>"
Response.Write "</table>"
%>

Result: a table row showing User ID and student42. This example initializes the value for demonstration; production code should use an already-established session value and should not expose sensitive session identifiers.

Related lessons: Classic ASP session variables and Response.Write output.

Safely display submitted text that contains quotes ↑

Quotes in input are not automatically unsafe, but displaying untrusted text without output encoding can allow HTML injection. Use Server.HTMLEncode() for text inserted into HTML content; it is separate from VBScript quote escaping.

A form demonstration: the input uses HTML entities; the server HTML-encodes submitted text before displaying it.

<form method="post" action="">
  <label for="message">Your message</label>
  <input type="text" name="message" id="message" value="She said &quot;Hello&quot;">
  <button type="submit">Display safely</button>
</form>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
    Dim message
    message = Request.Form("message")
    Response.Write "<p>You entered: " & Server.HTMLEncode(message) & "</p>"
End If
%>

See Classic ASP forms and Request.Form for reading form fields, and handling text line breaks when displaying multiline input.

Replace or remove quotation marks in a string ↑

When you need to change quotation marks in a text value, Replace() can search for Chr(34). This changes the text value itself; it does not perform HTML output encoding or make a SQL statement safe.

Replace double quotes with apostrophes.

Dim originalText, updatedText
originalText = "She said ""Hello""."
updatedText = Replace(originalText, Chr(34), "'")
Response.Write updatedText

Output: She said 'Hello'.

Double embedded quote characters in a value

For formats that represent an embedded quote by repeating it (such as a quoted CSV field), you can double quotation marks in the text value.

Double quotation marks inside a value without changing the original text.

Dim originalText, escapedText
originalText = "She said ""Hello""."
escapedText = Replace(originalText, Chr(34), Chr(34) & Chr(34))
Response.Write Server.HTMLEncode(escapedText)

Displayed output: She said ""Hello"".

SQL note: do not construct SQL statements by manually escaping input with quote replacements. Use parameterized queries for database values. HTML encoding also does not replace SQL parameterization.

Related: the VBScript Replace() function and Classic ASP database connections.

Common mistakes and troubleshooting ↑

ProblemLikely causeSolution
VBScript syntax error or unterminated stringA quote inside a string is not doubledReplace an embedded " with "", or concatenate Chr(34)
Visible text shows Session("userid")The expression was placed inside a quoted HTML stringConcatenate the value outside the string and encode it for display
Output includes &quot; literallyThe entity was HTML-encoded againUse Chr(34) or emit the entity as appropriate for the output context
HTML attribute breaksEmbedded attribute quotes terminate the VBScript stringDouble the attribute quotes in the VBScript literal
Apostrophe unexpectedly comments out codeSingle quote appears outside a VBScript stringUse double quotes for VBScript string literals

Frequently asked questions ↑

How can I print one double quote in Classic ASP?

Use Response.Write Chr(34) or Response.Write """". Both produce one quotation-mark character.

How do I put double quotes inside a VBScript string?

Repeat each embedded quote. For example, "She said ""Hello""" represents the text She said "Hello".

Does VBScript use a backslash to escape quotation marks?

No. Double the quote character or use Chr(34); do not rely on the backslash syntax used in other languages.

Is doubling a quote enough to display form input safely?

No. Doubling quote characters only controls VBScript source syntax. Use context-appropriate encoding when displaying submitted values, and validate input on the server.

Is &quot; the same as Chr(34)?

No. Chr(34) creates a quote character in a VBScript value; &quot; is an HTML entity that the browser decodes while rendering HTML.

Back to top ↑


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer