Share via


DexAsk()

The DexAsk() function creates a dialog box containing a message and up to three user-defined buttons. It returns a value indicating which button is clicked by the user. Processing stops while the system waits for the user to respond.

Syntax

DexAsk(prompt, button1, button2, button3)

Parameters

prompt - A string with the message to be displayed in the dialog box.

button1 - A string containing the label for the first button in the dialog box.

button2 - A string containing the label for the second button in the dialog box.

button3 - A string containing the label for the third button in the dialog box.

Return value

An integer indicating which button the user clicked. It corresponds to one of the following values:

Value

Description

1

Button 1

2

Button 2

3

Button 3

Comments

If you want to use fewer than three buttons in the dialog box, use the empty string ("") for the buttons you don't want to use. For example, to display only two buttons, supply the button text for the first two buttons and the empty string for the third button.

Examples

The following C# example shows the DexAsk() function being used to display a question to the user asking whether to save changes. The value of the answer variable depends on the button the user clicked.

Int16 answer;
answer = Dynamics.Forms.SyVisualStudioHelper.Functions.DexAsk.Invoke(
"Do you want to save the changes?", "Yes", "No", "Cancel");
if (answer == 1)
{
    // Yes, save the changes
}

if (answer == 2)
{
    // No, don't save the changes
}

if (answer == 3)
{
    // Cancel was clicked
}

The following Visual Basic example shows the DexAsk() function being used to display a question to the user asking whether to save changes. The value of the answer variable depends on the button the user clicked.

Dim answer As Int16

answer = Dynamics.Forms.SyVisualStudioHelper.Functions.DexAsk _
    .Invoke("Do you want to save the changes?", "Yes", "No", "Cancel")

If answer = 1 Then
    'Yes, save the changes
End If

If answer = 2 Then
    'No, don't save the changes
End If

If answer = 3 Then
    'Cancel was clicked
End If