- Local time
- Today, 10:18
- Joined
- Feb 19, 2013
- Messages
- 17,228
There have been a few recent posts about msgboxes, so I thought I would share what I use.
Unlike inputboxes the msgbox does not have parameters to specify the top/left position - typically a msgbox appears mid screen and often well away from where the user is actually working. The problem is a msgbox has to be dialog to ensure it sits on top and stop further code running. So any changes to position have to done once the message form is open and consequently cannot be done by the calling code.
The attached is something I developed a while ago and have now extracted from the app it was used in to provide a demo. It has a limited range of options (although has been sufficient for my needs) but can easily be extended if required - see notes in the modules.
The function is called with one line of code as per msgbox and returns a result as per msgbox. The parameters are pretty much the same as msgbox.
pStr = txtHeader & ";" & txtMessage & ";" & Choose(fOptions, "vbOKOnly", "vbOKCancel", "vbYesNo", "vbYesNoCancel", "vbRetryCancel") & Choose(fImages, "", "+vbCritical", "+vbExclamation")
MsgBox "returns the vbNumber " & MsgBoxResult(pStr)
Hope some of you find it useful
Unlike inputboxes the msgbox does not have parameters to specify the top/left position - typically a msgbox appears mid screen and often well away from where the user is actually working. The problem is a msgbox has to be dialog to ensure it sits on top and stop further code running. So any changes to position have to done once the message form is open and consequently cannot be done by the calling code.
The attached is something I developed a while ago and have now extracted from the app it was used in to provide a demo. It has a limited range of options (although has been sufficient for my needs) but can easily be extended if required - see notes in the modules.
The function is called with one line of code as per msgbox and returns a result as per msgbox. The parameters are pretty much the same as msgbox.
pStr = txtHeader & ";" & txtMessage & ";" & Choose(fOptions, "vbOKOnly", "vbOKCancel", "vbYesNo", "vbYesNoCancel", "vbRetryCancel") & Choose(fImages, "", "+vbCritical", "+vbExclamation")
MsgBox "returns the vbNumber " & MsgBoxResult(pStr)
Hope some of you find it useful