Public Function FormattedMsgBox(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
Optional title As String = vbNullString, Optional HelpFile As Variant, Optional Context As Variant) As VbMsgBoxResult
On Error GoTo Err_Handler
'Taken from http://www.trigeminal.com/usenet/usenet015.asp
FormattedMsgBox = Eval("MsgBox(""" & Prompt & _
""", " & Buttons & ", """ & title & """)")
MsgBox "Error " & Err.Number & " in FormattedMsgBox procedure : " & vbCrLf & " - " & Err.Description
The following code allows bold text in a standard message box as well as standard features such as message box icons and more than one button.
You can also include context help items though I've never done so
The code uses the Eval function to format the first part of the code in BOLD text
It was originally taken from http://www.trigeminal.com/usenet/usenet015.asp
FormattedMsgBox "You are not currently connected to the Internet " & _
"@Location map data cannot be downloaded " & vbCrLf & vbCrLf & _
"Please try again later @", vbCritical, "No Internet connection"
Functions can also be included in the message box text.
In this example, it is being used with a function GetLatestWebVersion:
FormattedMsgBox "Currency Exchange Rates Tracker version " & GetLatestWebVersion () & " is now available for download " & vbCrLf & _
"from the Mendip Data Systems website " & _
"@Click YES to close the program and download the latest version now " & vbCrLf & _
"Click NO if you want to download this later @", _
vbExclamation + vbYesNo, "New version available"
This is included as one method of getting users' attention in an example database:
Click any image to view a larger version ...