Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
msgBox
I have a problem with my help menue so please dont just refer to it. i want
to have a messagebox that pops up when the user presses a button. the message box shall ask the user if he(she is sure if he wants to abort. i just dont get the syntax. I know to write the text on the box but how to choose how many and what type of buttons etc. i dont know. i dont know how to connect an event to certain button in the message box. please help me on this one!!!! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
msgBox
Message boxes return values (of type long integer). Luckily you do not need
to remember all of the integers as there are preset aliases for the values returned such as vbYes, vbNo and vbCancel. So for the simplest message boxes you can use a statement such as this if msgbox("Would you like to continue?", vbYesNo, "Continue") = vbYes then 'Do your stuff end if Note that the first itme in the Bracets is the Text of the message, The second item is the button type an the third item is the title. You can get a bit more elaborate with the button type by using the + sysmbol. Try the code below. Note that the message box is an information box with buttons abort/retry/ignore and that the 3rd button is the default reply... I used a variable to hold the value of the message box since there are 3 possible answers Sub test() Dim lngResponse As Long lngResponse = MsgBox("What do you want to do?", _ vbDefaultButton3 + vbInformation + vbAbortRetryIgnore, _ "What to Do?") If lngResponse = vbIgnore Then MsgBox "Pressed Ignore" ElseIf lngResponse = vbRetry Then MsgBox "Pressed Retry" Else MsgBox "Pressed Abort" End If End Sub -- HTH... Jim Thomlinson "april27" wrote: I have a problem with my help menue so please dont just refer to it. i want to have a messagebox that pops up when the user presses a button. the message box shall ask the user if he(she is sure if he wants to abort. i just dont get the syntax. I know to write the text on the box but how to choose how many and what type of buttons etc. i dont know. i dont know how to connect an event to certain button in the message box. please help me on this one!!!! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
msgBox
I think you want something like this:
If MsgBox("Do you want to abort this macro?", _ vbYesNo + vbDefaultButton2 + vbQuestion, _ "aborting macro") = vbYes Then Exit Sub End If RBS "april27" wrote in message ... I have a problem with my help menue so please dont just refer to it. i want to have a messagebox that pops up when the user presses a button. the message box shall ask the user if he(she is sure if he wants to abort. i just dont get the syntax. I know to write the text on the box but how to choose how many and what type of buttons etc. i dont know. i dont know how to connect an event to certain button in the message box. please help me on this one!!!! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
msgBox
Hi April27,
I have a problem with my help menue so please dont just refer to it. i want to have a messagebox that pops up when the user presses a button. the message box shall ask the user if he(she is sure if he wants to abort. i just dont get the syntax. I know to write the text on the box but how to choose how many and what type of buttons etc. i dont know. i dont know how to connect an event to certain button in the message box. please help me on this one!!!! Sub MsgBoxDemo() Select Case MsgBox("What do you want to do?" _ , vbAbortRetryIgnore + vbQuestion, "MsgBoxDemo") Case vbAbort MsgBox "Abort!", vbCritical Case vbRetry MsgBox "Retry!", vbExclamation Case vbIgnore MsgBox "Ignore", vbInformation End Select End Sub Regards, Jan Karel Pieterse Excel MVP http://www.jkp-ads.com Member of: Professional Office Developer Association www.proofficedev.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
msgbox in VBA | Excel Discussion (Misc queries) | |||
msgbox | Excel Discussion (Misc queries) | |||
msgbox | Excel Programming | |||
help with msgbox | Excel Programming | |||
Msgbox | Excel Programming |