MsgBox Statement

Menampilkan kotak dialog yang berisi pesan.

Sintaksis:


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

Parameter:

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:

Dinamakan konstan

Nilai integer

Definisi

MB_OK

0

Hanya menampilkan tombol OKE.

MB_OKCANCEL

1

Menampilkan tombol OK dan Batal.

MB_ABORTRETRYIGNORE

2

Menampilkan tombol Batalkan, Ulangi, dan Abaikan.

MB_YESNOCANCEL

3

Menampilkan tombol Ya, Tidak, dan Batal.

MB_YESNO

4

Menampilkan tombol Ya dan Tidak.

MB_RETRYCANCEL

5

Menampilkan tombol Ulangi dan Batal.

MB_ICONSTOP

16

Tambahkan ikon Berhenti pada dialog.

MB_ICONQUESTION

32

Tambahkan ikon Pertanyaan pada dialog.

MB_ICONEXCLAMATION

48

Tambahkan ikon Tanda Seru ke dialog.

MB_ICONINFORMATION

64

Tambahkan ikon Informasi pada dialog.

128

Tombol pertama pada dialog sebagai tombol utama.

MB_DEFBUTTON2

256

Tombol kedua pada dialog sebagai tombol utama.

MB_DEFBUTTON3

512

Tambahkan ikon Tanda Seru ke dialog.


Kode kesalahan:

5 Tidak sah dalam pemanggilan prosedur

Contoh:


Sub ExampleMsgBox
 Const sText1 = "Kesalahan tak diinginkan telah terjadi."
 Const sText2 = "Eksekusi program akan tetap berlanjut, bagaimanapun juga."
 Const sText3 = "Kesalahan"
 MsgBox(sText1 + Chr(13) + sText2,16,sText3)
 MsgBox(sText1 + Chr(13) + sText2, MB_ICONSTOP, sText3)
End Sub

Mohon dukung kami!