start a new line in a form message box

W

wendy

Hi,
I am creating a message box as part of a form template using the code:

vAnswer = MsgBox(Prompt:="text", Buttons:=vbOKOnly)
If vAnswer = vbOK Then
Exit Sub
End If

The text I'd like to enter is a reminder to do 3 things, and I'd like each
item to appear on a new line. The help file suggested inserting Chr(13) -- a
carriage return -- to start a new line, but I can't figure out how to do
this. If I add Chr(13) within the quotes, it just appears as part of the
text. If I end the quotes, add Chr(13) and restart the quotes, I get an
error when I test the form.

Any suggestions for how specify new lines within the Prompt for a message
box???

Thanks in advance
 
G

Greg

Wendy,

Use the & operator to conenct literal and string variables. Try one of
these:

Sub Text()

If MsgBox("Wash hands," & vbCr & "brush teeth," _
& vbCr & "and comb hair", vbOK) = vbOK Then
Exit Sub
End If
End Sub

Sub Text1()

If MsgBox("Wash hands," & Chr(13) & "brush teeth," _
& Chr(13) & "and comb hair", vbOK) = vbOK Then
Exit Sub
End If
End Sub
 

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