Multilined MsgBox

  • Thread starter Thread starter Carl Mankat
  • Start date Start date
C

Carl Mankat

If this is off post please direct me.
I
am having problems understanding how to make a MsgBox with more than
one line in the statement.

This: MsgBox "statement",,"Title" works.

This: Msgbox "Line one"
& "Line two",,"Title" doesn't work.

Also, should I use MsgBox as a function or method? I'm confused.

TIA,

Carl
 
Stuff the text into a string, and then use that (this makes the code easy to
write/read)

dim strMsg as string


strMsg = "This is the first line of text " & vbcrlf & _
"This is the 2nd line of text" & vbcrlf & _
"This i the 3rnd line of text


msgbox "hello",vbInformation,"example msg"

Also, try using the vbvInformation etc, as they make the msg box look very
nice....
 
How you use the message box depends on what you want it to do.
If you just want to display information for the user and expect the user to
take no action, then it is like this:
MsgBox "Here is Something You Should Know", vbInformation + vbOkOnly

If you want to do something based on a decision made by the user, then it is
like this:

If MsgBox("What Should I Do", vbQuestion + vbOkCancel) = vbCancel Then
'Do what you want to happen if the user clicked Cancel
Else
'Do what you want to happen if the user clicked OK
End If

Now, for the MultiLine:
Msgbox "This is Line One" & vbNewLine & "This is Line Two"
 
Back
Top