start a new line in a form message box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top