MsgBox Statement

Muestra un cuadro de diálogo que contiene un mensaje.

Sintaxis:


   MsgBox prompt As String [,buttons = MB_OK [,title As String]]
   response = MsgBox( prompt As String [,buttons = MB_OK [,title As String]])

Parámetros:

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:

Constante con nombre

Valor entero

Definición

MB_OK

0

Mostrar solo el botón «Aceptar».

MB_OKCANCEL

1

Mostrar los botones «Aceptar» y «Cancelar».

MB_ABORTRETRYIGNORE

2

Mostrar los botones «Interrumpir», «Reintentar» e «Ignorar».

MB_YESNOCANCEL

3

Mostrar los botones «Sí», «No» y «Cancelar».

MB_YESNO

4

Mostrar los botones «Sí» y «No».

MB_RETRYCANCEL

5

Mostrar los botones «Reintentar» y «Cancelar».

MB_ICONSTOP

16

Añadir el icono de parada crítica al cuadro de diálogo.

MB_ICONQUESTION

32

Añadir el icono de pregunta al cuadro de diálogo.

MB_ICONEXCLAMATION

48

Añadir el icono del signo de exclamación al cuadro de diálogo.

MB_ICONINFORMATION

64

Añade el icono de información al cuadro de diálogo.

128

El primer botón del cuadro de diálogo es el predeterminado.

MB_DEFBUTTON2

256

El segundo botón del cuadro de diálogo es el predeterminado.

MB_DEFBUTTON3

512

El tercer botón del cuadro de diálogo es el predeterminado.


Códigos de error:

5 Llamada a procedimiento no válida

Ejemplo:


Sub ExampleMsgBox
 Const sTexto1 = "Se ha producido un error inesperado."
 Const sTexto2 = "Sin embargo, la ejecución del programa continuará."
 Const sTexto3 = "Error"
 MsgBox(sText1 + Chr(13) + sText2,16,sText3)
 MsgBox(sText1 + Chr(13) + sText2, MB_ICONSTOP, sText3)
End Sub

¡Necesitamos su ayuda!