none
Using double quotes in strings

    Question

  • How do you use double quotes in strings, currently it converts " to two seperate single quotes. is there any way around this, or other escape sequences?
    Friday, November 28, 2008 6:41 AM

Answers

  • There isn't a way to escape quotes at the moment.  We're considering options - would love to hear ideas.
    Friday, November 28, 2008 3:18 PM

All replies

  • This should defiantly be possible, but like you I can't find a way either with the normal ways of escaping quotes not seeming to work. 
    Friday, November 28, 2008 2:23 PM
  • There isn't a way to escape quotes at the moment.  We're considering options - would love to hear ideas.
    Friday, November 28, 2008 3:18 PM
  • In older forms of basic, this was done with CHR$(34).

    of course, that was ASCII based, and I imagine that the SB strings are based on the .NET string, which are unicode.

    A "typical" collection of string manipulation functions consist of:

       ASC(str) - not covered in SB
       CHR$(charcode) - not covered in SB

       LEFT$(str,length) - covered by Text.GetSubText
       RIGHT$(str,length) - covered by Text.GetSubText
       MID$(str,first,len) - covered by Text.GetSubText

       STR$(num) - not covered in SB explicitly
       VAL(str) - not covered in SB

       HEX$(num) - not covered in SB
       OCT$(num) - not covered in SB

       LEN(str) - covered by Text.GetLength

       STRING$(length,charcode) - not covered in SB, and probably not really necessary
       STRING$(length,str) - not covered in SB, and probably not really necessary
       INSTR(first,str,substr) - covered by Text.StartsWith, Text.EndsWith, and Text.IsSubText

       UCASE$(str) - covered by Text.ConvertToUpperCase
       LCASE$(str) - covered by Text.ConvertToLowerCase

    and probably a few others if I were to scan QB and GWB.
    Friday, November 28, 2008 3:36 PM
  • With something like CHR, you would have to supply the list of numeric equivalents (which is not a bad thing - I use to have the Apple ASCII memorized due to constant use).

    What about borrowing an idea from Excel's Header/Footers?
    Using and ampersands - like;
    &" + "This is quoted." + &" + "  This is outside the quotes."

    Since (I think I read in a different thread) ampersands are used like the plus-sign in strings, maybe use a different character?
    Monday, December 01, 2008 3:48 PM
  • Hi,
    You may have gotten an answer by now -- this is an old thread, I see

    However,  one can set a constant to play as Double Quotes

    in Visual Basic:

    GLOBAL CONST DblQts as string = """"

    Then DblQts will issue   the  "   character in any string...

    Tuesday, June 02, 2009 6:33 PM
  • AlKatraz,

    Good suggestion.  In Small Basic it could be written as-

    DoubleQuotes = Text.GetCharacter(34)
    TextWindow.WriteLine("You can use the " + DoubleQuotes + " character in a string now"

    Tuesday, June 02, 2009 8:57 PM
  • You can use  " + "\"" + " in C# and 4 """" in VB.NET

    Ex:

    VB.NET
    Dim str As String = "Example String " & """" & "This is the String with double quotes." & """"
    MessageBox.Show(str)

    In VB.Net you can indicate that there is a double quote in a string by using 4 double quotes ("""").

    C#.NET
    string str = "Example String " + "\"" + "This is the String with double quotes." + "\"";
    MessageBox.Show(str); As you will notice in C# the double quote can be represented as double quote, back slash and again using two double quotes ("\"").
    Wednesday, August 12, 2009 7:11 PM
  • Text.GetCharacter(34)+"some text as a string"+Text.GetCharacter(34)

    gives: "some text as a string" in the output.

    Dan
    • Proposed as answer by Path_drc Saturday, August 07, 2010 9:15 PM
    Tuesday, November 24, 2009 9:16 PM