OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Message and Input Boxes<br />
Display of the Message Box<br />
If an information box contains several buttons, then a return value should be queried to determine which button<br />
has been pressed. The following return values are available in this instance:<br />
1, IDOK - Ok<br />
2, IDCANCEL - Cancel<br />
3, IDABORT - Abort<br />
4, IDRETRY - Retry<br />
5 - Ignore<br />
6, IDYES - Yes<br />
7, IDNO - No<br />
In the previous example, checking the return values could be as follows:<br />
Dim iBox as Integer<br />
iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION<br />
If MsgBox ("Do you want to continue?", iBox) = IDYES Then<br />
' or,<br />
If MsgBox ("Do you want to continue?", 292) = 6 Then<br />
' Yes button pressed<br />
Else<br />
' No button pressed<br />
End IF<br />
In addition to the information text and the parameter for arranging the information box, MsgBox also permits a<br />
third parameter, which defines the text for the box title:<br />
MsgBox "Do you want to continue?", 292, "Box Title"<br />
If no box title is specified, the default is “soffice”.<br />
Input Box For Querying Simple Strings<br />
The InputBox function queries simple strings from the user. It is therefore a simple alternative to configuring<br />
dialogs. InputBox receives three standard parameters:<br />
An information text.<br />
A box title.<br />
A default value which can be added within the input area.<br />
InputVal = InputBox("Please enter value:", "Test", "default value")<br />
Display of the Input Box<br />
The dimensions of the InputBox window cannot be changed.<br />
If the user clicks the OK button, the InputBox returns the string typed by the user (or the default string if it<br />
was not changed).<br />
If the user clicks the Cancel button or closes the window, the InputBox returns an empty string.<br />
48 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010