Replace all MsgBox calls that display only an OK message with the following OkMsg sub. It automatically defaults the icon to vbInformation, and the title to a global constant defined at startup. None to all of the parameters can be passed to override the defaults. Another advantage is that the OkMsg sub saves and restores the state of the mousepointer, so you don’t get an hourglass outside the MsgBox:
Sub OkMsg(Optional sMsg As String = _ "Press OK to Continue", Optional vIcon = _ vbInformation, Optional sTitle As String = APPNAME) Dim iMouse As Integer iMouse = Screen.MousePointer Screen.MousePointer = vbDefault MsgBox sMsg, vIcon, sTitle Screen.MousePointer = iMouseEnd Sub
To call this sub, use this syntax:
OkMsg "The Record is Saved" OkMsg "The date entered is out of range!", _ vbExclamation, "INPUT ERROR"
Always declare the global constant:
Global Const APPNAME = "Management System"
Note: VB3 users must change the optional parameters to required, and VB4 users must insert IsMissing checks to assign defaults to missing optional parameters.