THUND3R
THUND3R

Reputation: 15

how to show quotation marks inside of a msgbox

Can someone please tell me a way (or similar) to use (") in a text in vb. eg. msgbox("some text here "other text here" more text" & vbnewline & "next line of text").

If you still dont get what I mean, all I need is this section ("other text") including the (") to show in a msgbox.

Upvotes: 1

Views: 5138

Answers (3)

Sam Axe
Sam Axe

Reputation: 33738

Escaping the quotes never looks quite right to me.

I like using a fluent-ish API instead:

<Extension>
Public Function Quote(byval value as String) As String
  Return value & CHR(34)
End Function

<Extension>
Public Function SurroundWith(ByVal value As String, ByVal surround As String) As String
  Return surround & value & surround
End Function

Usage:

Console.WriteLine("Hello there!  I'm Bob ".Quote & "Buddy".Quote & " Holly.")

Console.WriteLine("Hello there!  I'm Bob " & "Buddy".SurroundWith(CHR(34)) & " Holly.")

Upvotes: 0

Dutchs
Dutchs

Reputation: 652

Either escape the quote by another quote Dim q as String = """" would be one quote, or use ControlChars.Quote

Upvotes: 2

NoWayIn
NoWayIn

Reputation: 51

All you have to do is use double quotes.
For example : Dim abc as string = "Using double ""quotes""

So for MsgBox you would do the same. MsgBox("Use double ""quotes"" to show quotes")

Upvotes: 0

Related Questions