You are fighting the VB.Net language specification that treats the three different double quote characters as the same character when used in code statements.
From String Literals:
A string literal is a sequence of zero or more Unicode characters
beginning and ending with an ASCII double-quote character, a Unicode
left double-quote character, or a Unicode right double-quote
character. Within a string, a sequence of two double-quote characters
is an escape sequence representing a double quote in the string.
StringLiteral
: DoubleQuoteCharacter StringCharacter* DoubleQuoteCharacter
;
DoubleQuoteCharacter
: '"'
| '<unicode left double-quote 0x201c>'
| '<unicode right double-quote 0x201D>'
;
StringCharacter
: '<Any character except DoubleQuoteCharacter>'
| DoubleQuoteCharacter DoubleQuoteCharacter
;
In the above quoted specification, the usage of "ASCII double-quote character" means the inch character or Chrw(34).
Prior to VS2015, you couldnot even paste """1""" = "””1””"
into the code editor without it being automatically converted to """1""" = """1"""
.
If you need to construct code statements that include the Unicode double quotes, they will need to be constructed using their respective character representations.
Const ucDoubleLeftQuote As Char = ChrW(&H201C) ' "“"c
Const ucDoubleRightQuote As Char = ChrW(&H201D) ' "”"c
Const asciiDoubleQuote As Char = ChrW(34) ' """"c
Dim asciiQuoted As String = """1"""
Dim asciiQuotedv2 As String = asciiDoubleQuote & "1" & asciiDoubleQuote
Dim unicodeQuoted As String = ucDoubleLeftQuote & "1" & ucDoubleLeftQuote
MessageBox.Show((asciiQuoted = asciiQuotedv2).ToString()) ' yields true
MessageBox.Show((asciiQuoted = unicodeQuoted).ToString()) ' yields false
Edit: To demonstrate the substitution of the ASCII double quote for any Unicode Double quotes in string literals by the VB compiler, please consider the following code.
Module Module1
Sub Main()
T1("““ 1 ””") ' unicode quotation marks left and right
T2(""" 1 """) ' ascii quotation mark
End Sub
Sub T1(s As String) ' dummy method to highlight unicode quotation mark
End Sub
Sub T2(s As String) ' dummy method to highlight asci quotation mark
End Sub
End Module
This code will yield the following IL when viewed in ILDASM.
.method public static void Main() cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01 00 00 00 )
// Code size 24 (0x18)
.maxstack 8
IL_0000: nop
IL_0001: ldstr "\" 1 \""
IL_0006: call void ConsoleApp1.Module1::T1(string)
IL_000b: nop
IL_000c: ldstr "\" 1 \""
IL_0011: call void ConsoleApp1.Module1::T2(string)
IL_0016: nop
IL_0017: ret
} // end of method Module1::Main
IL_0001: ldstr "\" 1 \""
corresponds to the loading of the string for the call statement: T1("““ 1 ””")
.
You can see, this is identical to IL_000c: ldstr "\" 1 \""
that corresponds to the loading of the string for the call statement: T2(""" 1 """)
.