locked
Quotation marks RRS feed

  • Question

  • writer.WriteLine(

    "^"c & aa & bb & cc & dd & "!"c)

    How does one inject a quotation mark in the above instead of the "^"c and "!"c. """c does not work. Tried '"' and "\"".

    First chance I had of using Visual Basic since last year.

    Sunday, June 6, 2010 2:28 AM

Answers

  • In VB.NET we use two double quotations.

       Dim a As String = "This string has ""Double Quotes"" in it."
       Dim quoteChar As Char = """"c
    

     

    -Hazelrah

    • Proposed as answer by A.m.a.L Hashim Sunday, June 6, 2010 6:15 AM
    • Marked as answer by Plasman Sunday, June 6, 2010 5:08 PM
    Sunday, June 6, 2010 2:52 AM
  • here are 2 ways: you can escape the quotation with another quotation mark or you can use the ASCII code for a quotation mark

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Debug.WriteLine("""" & "aa bb cc dd" & """")
        'or this
        Debug.WriteLine("""aa bb cc dd""")
      End Sub
    
      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Debug.WriteLine(Chr(34) & "aa bb cc dd" & Chr(34))
      End Sub
    • Proposed as answer by A.m.a.L Hashim Sunday, June 6, 2010 6:15 AM
    • Marked as answer by Plasman Sunday, June 6, 2010 5:09 PM
    Sunday, June 6, 2010 5:08 AM

All replies

  • In VB.NET we use two double quotations.

       Dim a As String = "This string has ""Double Quotes"" in it."
       Dim quoteChar As Char = """"c
    

     

    -Hazelrah

    • Proposed as answer by A.m.a.L Hashim Sunday, June 6, 2010 6:15 AM
    • Marked as answer by Plasman Sunday, June 6, 2010 5:08 PM
    Sunday, June 6, 2010 2:52 AM
  • here are 2 ways: you can escape the quotation with another quotation mark or you can use the ASCII code for a quotation mark

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Debug.WriteLine("""" & "aa bb cc dd" & """")
        'or this
        Debug.WriteLine("""aa bb cc dd""")
      End Sub
    
      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Debug.WriteLine(Chr(34) & "aa bb cc dd" & Chr(34))
      End Sub
    • Proposed as answer by A.m.a.L Hashim Sunday, June 6, 2010 6:15 AM
    • Marked as answer by Plasman Sunday, June 6, 2010 5:09 PM
    Sunday, June 6, 2010 5:08 AM