Creating a Multi Line message box. (2 Viewers)

Neil07979

Registered User.
Local time
Today, 15:06
Joined
Jul 16, 2007
Messages
25
Hi all,

I'm trying to create a simple message box in VBA, which I have done. I need to get the text that I enter as the message to split over 2 or 3 lines; is there any way that this can be done? I'd also like to have some of the text in Bold?

Would this be possible using the message box function - or would I need to create a form that will do this for me?

Thanks in advance
 

chergh

blah
Local time
Today, 15:06
Joined
Jun 15, 2004
Messages
1,414
You want to use vbCrLf like this:

Code:
msgbox("1st line" & vbcrlf & "2nd line" & vbcrlf & "3rd line")

There is a post here about bolding text in a message box
 
Last edited:

Neil07979

Registered User.
Local time
Today, 15:06
Joined
Jul 16, 2007
Messages
25
Thanks - just what i'm looking for.
 

DCrake

Remembered
Local time
Today, 15:06
Joined
Jun 8, 2005
Messages
8,632
Here is a variation of the MsgBox function that has tags in it for bold text

Code:
Function FMsgBox(Prompt As String, Optional Btns As Integer, Optional Ttl As String = vbNullString, _
 Optional HFile As Variant, Optional Context As Variant) As Integer

If IsMissing(HFile) Or IsMissing(Context) Then
    FMsgBox = Eval("msgbox(""" & Prompt & """, " & Btns & ", """ & Ttl & """)")
Else
    FMsgBox = Eval("msgbox(""" & Prompt & """, " & Btns & ", """ & Ttl & """, """ & HFile & """, " & Context & ")")
End If

End Function


If you code your message box as follows

Call fMsgBox("First Line is Bold@Second line is not@",VbOkOnly,"Formatted Message Box"

Whatever is outside of the @ tags is in bold.
 

Users who are viewing this thread

Top Bottom