Evaluating Which Button Was Pressed in a User-Defined DialogLast reviewed: February 9, 1998Article ID: Q80070 |
The information in this article applies to:
SUMMARYThe following Microsoft WordBasic macro provides an example of how to evaluate which button was pressed in a user-defined dialog box. The macro uses a Select Case structure to evaluate the value returned by the dialog function; N = Dialog(DialogRecord).
MORE INFORMATIONSpecific values are assigned to the buttons in a dialog box. The function N=Dialog(DialogRecord) stores the value assigned to the button in the dialog box for later use. (DialogRecord) is the name that the user gives to the dialog box. The values of "N" are as follows:
Button Type N=Dialog(DialogRecord) Value Assigned ----------- ---------------------- -------------- OK button -1 Always Cancel button 0 Always Pushbutton-1 1 According to order Pushbutton-2 2 According to order Pushbutton-3 3 According to order Pushbutton-M M According to orderThe values for the pushbuttons are chronologically assigned, meaning the first pushbutton is assigned one, the second two, and so on. The OK button always has the value minus one (-1) and the Cancel button always has the value zero (0). The following macro demonstrates how the evaluation works. Inside the case statements various types of tasks can be performed. This example uses message boxes for simplicity.
Sub MAIN 'Macro Starts Here Begin Dialog UserDialog 320, 98, "Example Macro" PushButton 10, 6, 88, 21, "Button-1" PushButton 10, 30, 88, 21, "Button-2" PushButton 10, 54, 88, 21, "Button-3" OKButton 165, 18, 88, 21 CancelButton 166, 46, 88, 21 End Dialog Dim MyDlg As Dialog UserDialog 'Mydlg came be change to anything N = Dialog(MyDlg) Select Case N Case - 1 MsgBox("Ok was Pressed!", "OK-Bottom", 64) Case 0 MsgBox("Cancel was Pressed!", "Cancel-Bottom", 16) Case 1 MsgBox("Button-1 was Pressed!", "PushBottom-1", 64) Case 2 MsgBox("Button-2 was Pressed!", "PushBottom-2", 64) Case 3 MsgBox("Button-3 was Pressed!", "PushBottom-3", 64) Case Else Goto Bye End Select Bye: End Sub 'End of MacroFor more information, search for "WordBasic Programming Language" and "Dialog" using the Help menu. Kbcategory: kbusage kbmacro KBSubcategory: |
Additional query words: pushbutton dialog winword2 word6 6.0.1
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |