ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Msgbox (https://www.excelbanter.com/excel-programming/323050-msgbox.html)

Alvin Hansen[_2_]

Msgbox
 
How do i use VKokCancel in a message box
I can't get it to work?

regards alvin


JE McGimpsey

Msgbox
 
One way:


Dim nResult As Long
nResult = MsgBox(Prompt:="Erase your hard drive?", _
Buttons:=vbOKCancel)
If nResult = vbCancel Then
MsgBox "You cancelled..."
Else
MsgBox "Just kidding!"
End If


,
Alvin Hansen wrote:

How do i use VKokCancel in a message box
I can't get it to work?


Bob Phillips[_6_]

Msgbox
 
Set a variable to the MsgBox results

ans = MsgBox(...)

and test that for vbOK or vbCancel

If ans = vbOK then
...
ElseIf ans = vbCancel Then
...

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alvin Hansen" wrote in message
...
How do i use VKokCancel in a message box
I can't get it to work?

regards alvin




Tom Ogilvy

Msgbox
 
Sub ABCD()
Dim ans As Long
ans = MsgBox("Ok or Cancel?", vbOKCancel)
If ans = vbOK Then
MsgBox "You clicked OK"
ElseIf ans = vbCancel Then
MsgBox "You clicked cancel"
End If
End Sub

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
How do i use VKokCancel in a message box
I can't get it to work?

regards alvin




Alvin Hansen[_2_]

Msgbox
 
Thank you all

So simpel............................................ .

regards alvin


"Tom Ogilvy" skrev:

Sub ABCD()
Dim ans As Long
ans = MsgBox("Ok or Cancel?", vbOKCancel)
If ans = vbOK Then
MsgBox "You clicked OK"
ElseIf ans = vbCancel Then
MsgBox "You clicked cancel"
End If
End Sub

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
How do i use VKokCancel in a message box
I can't get it to work?

regards alvin





Coolbreeze

Msgbox
 
Funny AND helpful... Cheers

"JE McGimpsey" wrote:

One way:


Dim nResult As Long
nResult = MsgBox(Prompt:="Erase your hard drive?", _
Buttons:=vbOKCancel)
If nResult = vbCancel Then
MsgBox "You cancelled..."
Else
MsgBox "Just kidding!"
End If


,
Alvin Hansen wrote:

How do i use VKokCancel in a message box
I can't get it to work?




All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com