putting double quotes in a string

G

Guest

I want to add double quotes in as string. The string gets value from other
variable as well.

Suppose
myvariable = "Sam"

"Hello " & [myvariable] &" Good day".

I want that output with myvariable value in double quotes like

Hello "Sam" Good day
 
R

RoyVidar

Abdul Basit wrote in message
I want to add double quotes in as string. The string gets value from other
variable as well.

Suppose
myvariable = "Sam"

"Hello " & [myvariable] &" Good day".

I want that output with myvariable value in double quotes like

Hello "Sam" Good day

Couple of versions:

MsgBox "Hello """ & myvariable & """ Good day"
MsgBox "Hello " & chr$(34) & myvariable & chr$(34) & " Good day"
 
B

Brendan Reynolds

Public Sub QuotesInString()

Dim myVariable As String

myVariable = "Sam"
Debug.Print "Hello """ & myVariable & """ Good day"

End Sub

Result in Immediate window ...

QuotesInString
Hello "Sam" Good day
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top