From: OssieMac on
Hi,

It is not a function; it is a constant. If you lookup msgbox function and
msgbox constants in Help you will find out more about it. The following is a
small example of its use where the users selection is returned to a variable.

Sub test()
Dim Response As Variant

Response = MsgBox("Do you want to continue?", vbOKCancel)

If Response = vbOK Then
MsgBox "User selected OK"
'Insert required code here
Else
MsgBox "User cancelled." & vbLf & _
"Processing terminated."

End If

End Sub



--
Regards,

OssieMac


"G Lykos" wrote:

> Thanks!
> George
>
>
> .
>
From: Chip Pearson on

>Dim Response As Variant

You'll get Intellisense support and lose the overhead inherent in
Variants if you declare Response as

Dim Response As VbMsgBoxResult


VbMsgBoxResult is the enum that defines vbYes, vbNo, and all the other
MsgBox constants.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]




On Sat, 13 Feb 2010 14:51:01 -0800, OssieMac
<OssieMac(a)discussions.microsoft.com> wrote:

>Hi,
>
>It is not a function; it is a constant. If you lookup msgbox function and
>msgbox constants in Help you will find out more about it. The following is a
>small example of its use where the users selection is returned to a variable.
>
>Sub test()
>Dim Response As Variant
>
>Response = MsgBox("Do you want to continue?", vbOKCancel)
>
>If Response = vbOK Then
> MsgBox "User selected OK"
> 'Insert required code here
>Else
> MsgBox "User cancelled." & vbLf & _
> "Processing terminated."
>
>End If
>
>End Sub