HaPhan HaPhan - 6 months ago 19
Vb.net Question

add " into String variable

As the question state, I need to add the " character into a string variable. Is it possible ?
I tried

Keys.OemQuote.ToString
... and to my surprise, it says that that key is Oem7. They both share the same key code of 222 ?

So now I'm stuck, and I can't search anything related to that " since godgle filter it out automatically.

I need it since my application have to work with an excel file in which i need to put the " into one of the cell.

Answer

Two options:

Dim someString As String = "Hello " & Chr(34) & "World" & Chr(34)
Dim someString2 As String = "Hello ""World"""

Possibly you're worried about Unicode here... but if this is a some unicode character that is only similar to the ascii 34 double-quote, VB.Net has unicode support in the language. Just paste the character into a string literal.

Comments