2 more questions on message boxes

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

Guest

Question One:
When entering lengthy notes in the VB screen, how do I put a line break in
that does't mess up the code? I'm really just asking for a line break to
make it easier for me to enter and edit the message box text.

Question Two:
What is the code I use to name the message box; the text in the blue header
of the message box?

Thanks for your answers!
 
1) You may find it easier to place the text into a variable then use the
variable in the MsgBox.

Example:
strMsg = "This is a long message." & vbCrLf & "That needs a line break"
MsgBox strMsg, vbOkOnly + vbExclamation, "My Message Box"

or, if you need a return value:
lngRetValue = MsgBox(strMsg, vbYesNo + vbQuestion, "My Message Box")

vbCrLf is a built-in constant for Carraige Return/Line Feed. You could also
concatenate in two Chr() functions with the appropriate character numbers,
but the constant is easier. Another option, if you have a really long
message, is to break up the message into multiple lines as you assign it to
the variable.

Example:
strMsg = "This is a long message." & vbCrLf & "That needs a line break"
strMsg = strMsg & vbCrLf & "I decided to add a third line."

2) Adding text to the blue title bar of the message box is done by the last
argument in the example above. In this case, the blue title bar will show
"My Message Box" (without the quotes).
 
Question One:
When entering lengthy notes in the VB screen, how do I put a line break in
that does't mess up the code? I'm really just asking for a line break to
make it easier for me to enter and edit the message box text.

Question Two:
What is the code I use to name the message box; the text in the blue header
of the message box?

Thanks for your answers!

I think your referring to the text in the code window itself, not in
the displayed message box itself, correct?

Add a space and underscore at the end of your code line, then continue
on the next line.

MsgBox "This is a very long line on the screen." _
& "This is on the next line."
The above will appear all on one line in the message itself.
 
Back
Top