How to: Put Quotation Marks in a String (Windows Forms)
Sometimes you might want to place quotation marks (" ") in a string of text. For example:
She said, "You deserve a treat!"
As an alternative, you can also use the Quote field as a constant.
To place quotation marks in a string in your code
In Visual Basic, insert two quotation marks in a row as an embedded quotation mark. In Visual C# and Visual C++, insert the escape sequence \" as an embedded quotation mark. For example, to create the preceding string, use the following code.
Private Sub InsertQuote() TextBox1.Text = "She said, ""You deserve a treat!"" " End Sub
Insert the ASCII or Unicode character for a quotation mark. In Visual Basic, use the ASCII character (34). In Visual C#, use the Unicode character (\u0022).
Private Sub InsertAscii() TextBox1.Text = "She said, " & Chr(34) & "You deserve a treat!" & Chr(34) End Sub
In this example, you cannot use \u0022 because you cannot use a universal character name that designates a character in the basic character set. Otherwise, you produce C3851. For more information, see Compiler Error C3851.
TextBox Control Overview (Windows Forms)
How to: Control the Insertion Point in a Windows Forms TextBox Control
How to: Create a Password Text Box with the Windows Forms TextBox Control
How to: Create a Read-Only Text Box (Windows Forms)
How to: Select Text in the Windows Forms TextBox Control
How to: View Multiple Lines in the Windows Forms TextBox Control
TextBox Control (Windows Forms)