Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Apr 7, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Use the MsgBox Wrapper to Replace OK

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 = iMouse
End 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.
Fabio A.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date