Screen I/O Functions

From Apache OpenOffice Wiki
Jump to: navigation, search

Basic provides statements and functions to display information on the screen or to get information from the user:

  • The Print statement displays strings or numeric expressions in a dialog. Multiple expressions are separated by commas that result in a tab distance between the expressions, or semicolons that result in a space between the expressions. For example:
  e = 2.718
  Print e                  ' displays "2.718"
  Print "e =" ; e          ' displays "e = 2.718"
  Print "e =" , e          ' displays "e = 2.718"
  • The MsgBox function displays a dialog box containing a message. Additionally, the caption of the dialog, buttons, such as OK, Cancel, Yes and No, and icons, such as question mark and exclamation mark, that are to be displayed are specified. The result then can be evaluated. For example:
  ' display a message box with an exclamation mark and OK and Cancel buttons
  ret& = Msgbox ("Changes will be lost. Proceed?", 48 + 1, "Warning")
  ' show user's selection. 1 = OK, 2 = Cancel
  Print ret&
  • The InputBox function displays a prompt in a dialog where the user can input text. The input is assigned to a variable. For example:
  ' display a dialog with "Please enter a phrase:" and "Dear User" as caption
  ' the dialog contains an edit control and the text entered by the user
  ' is stored in UserText$ when the dialog is closed with OK. Cancel returns "" 
  UserText$ = InputBox( "Please enter a phrase:", "Dear User" )
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages