AnswerBox (function)

Syntax

AnswerBox(prompt [,[button1] [,[button2] [,button3]]]]])

Description

Displays a dialog box prompting the user for a response and returns an Integer indicating which button was clicked (1 for the first button, 2 for the second, and so on).

Comments

The AnswerBox function takes the following parameters:

 

Parameter

Description

 

Prompt

Text to be displayed above the text box. The prompt parameter can be any expression convertible to a String.

 

 

The Basic Control Engine script resizes the dialog box to hold the entire contents of prompt, up to a maximum width of 5/8 of the width of the screen and a maximum height of 5/8 of the height of the screen. It also word-wraps any lines too long to fit within the dialog box and truncates all lines beyond the maximum number of lines that fit in the dialog box.

 

 

You can insert a carriage-return/line-feed character in a string to cause a line break in your message.

 

 

A runtime error is generated if this parameter is Null.

 

Button1

Text for the first button. If omitted, then "OK" and "Cancel" are used. A runtime error is generated if this parameter is Null.

 

Button2

Text for the second button. A runtime error is generated if this parameter is Null.

 

Button3

Text for the third button. A runtime error is generated if this parameter is Null.

 

The width of each button is determined by the width of the widest button.

The AnswerBox function returns 0 if the user selects Cancel.

R% = AnswerBox("Copy files?")

R% = AnswerBox("Copy files?","Save","Restore","Cancel")

 

 

Example

This example displays a dialog box containing three buttons. It displays an additional message based on which of the three buttons is selected.

Sub Main()

  r% = AnswerBox("Temporary File Operation?","Save","Remove","Cancel")
  Select Case r%
    Case 1
      MsgBox "Files will be saved."
    Case 2
      MsgBox "Files will be removed."
    Case Else
      MsgBox "Operation canceled."
    End Select
End Sub

See Also

MsgBox (statement); AskBox$ (function); AskPassword$ (function); InputBox, InputBox$ (functions); OpenFilename$ (function); SaveFilename$ (function); SelectBox (function).

Notes

AnswerBox displays all text in its dialog box in 8-point MS Sans Serif.

 

 

 

More information

A