Mendip Data Systems

Database applications for businesses and schools

LogoTransparent

 

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 & """)")

   

Exit_Handler:

   Exit Function

 

Err_Handler:

   MsgBox "Error " & Err.Number & " in FormattedMsgBox procedure : " & vbCrLf & "   - " & Err.Description

   

   Resume Exit_Handler

   

End Function

Code Samples for Businesses, Schools & Personal Use

Updated 03/07/2017            

 

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

 

Code:

Formatted Message Box

Screenshots

For example:

 

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:

An Attention Seeking Database

FormattedMsgBox2 FormattedMsgBox1

Click any image to view a larger version ...

Return to Code Samples Page