LibreOffice 25.2 帮助
显示一个含有消息的对话框,并返回一个值。
MsgBox (Prompt As String [,Buttons = MB_OK [,Title As String]]) As Integer
prompt: String expression displayed as a message in the dialog box. Line breaks can be inserted with Chr$(13).
title: String expression displayed in the title bar of the dialog. If omitted, the title bar displays the name of the respective application.
buttons: Any integer expression that specifies the dialog type, as well as the number and type of buttons to display, and the icon type. buttons represents a combination of bit patterns, that is, a combination of elements can be defined by adding their respective values:
| 已命名常量 | 整数值 | 定义 | 
|---|---|---|
| MB_OK | 0 | 仅显示「确定」按钮。 | 
| MB_OKCANCEL | 1 | 显示「确定」和「取消」按钮。 | 
| MB_ABORTRETRYIGNORE | 2 | 显示「中止」「重试」和「忽略」按钮。 | 
| MB_YESNOCANCEL | 3 | 显示「是」「否」和「取消」按钮。 | 
| MB_YESNO | 4 | 显示「是」和「否」按钮。 | 
| MB_RETRYCANCEL | 5 | 显示「重试」和「取消」按钮。 | 
| MB_ICONSTOP | 16 | 在对话框中添加「停止」图标。 | 
| MB_ICONQUESTION | 32 | 在对话框中添加「问号」图标。 | 
| MB_ICONEXCLAMATION | 48 | 在对话框中添加「感叹号」图标。 | 
| MB_ICONINFORMATION | 64 | 在对话框中添加「信息」图标。 | 
| 
 | 128 | 将对话框中的第一个按钮作为默认按钮。 | 
| MB_DEFBUTTON2 | 256 | 将对话框中的第二个按钮作为默认按钮。 | 
| MB_DEFBUTTON3 | 512 | 将对话框中的第三个按钮作为默认按钮。 | 
整数
| 已命名常量 | 整数值 | 定义 | 
|---|---|---|
| IDOK | 1 | 确定 | 
| IDCANCEL | 2 | 取消 | 
| IDABORT | 3 | 中止 | 
| IDRETRY | 4 | 重试 | 
| IDIGNORE | 5 | 忽略 | 
| IDYES | 6 | 是 | 
| IDNO | 7 | 否 | 
Sub ExampleMsgBox
Dim sVar As Integer
 sVar = MsgBox("Las Vegas")
 sVar = MsgBox("Las Vegas",1)
 sVar = MsgBox( "Las Vegas",256 + 16 + 2,"Dialog title")
 sVar = MsgBox("Las Vegas", MB_DEFBUTTON2 + MB_ICONSTOP + MB_ABORTRETRYIGNORE, "Dialog title")
End Sub