Reputation: 15
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
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
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
Reputation: 652
Either escape the quote by another quote Dim q as String = """"
would be one quote, or use ControlChars.Quote
Upvotes: 2
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