You are on page 1of 6

http://purnamayasa.wordpress.

com © 2011 oleh I Made Purnama Yasa

Message Box

Visual Basic 2005 Express

Pada modul ini saya akan menjelaskan bagaimana cara menampilkan pesan (Message
Box) pada program yang dibuat menggunkan Microsoft Visual Basic 2005 Express
Edition. Untuk lebih jelasnya ikuti langkah-langkah berikut ini.

Langkah-langkahnya:

1. Buka program Microsoft Visual Basic 2005 Express Edition, dengan mengikuti
langkah-langkah berikut ini:
 Klik tombo Start pada Task Bar
 Klik menu All Programs
 Klik menu Microsoft Visual Basic 2005 Express Edition
2. Pada program Microsoft Visual Basic 2005 Express Edition, buat prroject baru.
Dengan mengikuti langkah-langkah berikut ini:
 Klik menu File
 Klik menu New Project...

Setelah mengklik menu New Project, akan muncul jendela New Project

Gambar 1. Jendela New Project

Pada jendela New Project

 Pilih yang Windows Application


 Pada name ketikkan MessageBox, untuk nama project-nya
 Klik OK

1
http://purnamayasa.wordpress.com © 2011 oleh I Made Purnama Yasa

Desain Form

Langkah selanjutnya adalah membuat desain formnya, untuk desainya bisa melihat pada
gambar 2.

GroupBox

Button

Gambar 2. Desain form

Mengatur Properties

 Properties Form

Klik pada area form yang kosong, kemudian atur properties-nya seperti tabel 1.

Tabel 1. Properties Form

Properties Value
Name
Name frmMain
FormBorderStyle FixedSingle
MaximizeBox False
MinimizeBox False
StartPosition CenterScreen
Text Message Box

 Properties Button

1 4

2 5

3 6

Properties Button 1

Klik pada tombol 1, kemudian atur properties-nya seperti tabel 2.

2
http://purnamayasa.wordpress.com © 2011 oleh I Made Purnama Yasa

Tabel 2. Properties Button 1

Properties Value
Name
Name Button1
Text Information Message

Properties Button 2

Klik pada tombol 2, kemudian atur properties-nya seperti tabel 3.

Tabel 3. Properties Button 2

Properties Value
Name
Name Button2
Text Critical Message

Properties Button 3

Klik pada tombol 3, kemudian atur properties-nya seperti tabel 4.

Tabel 4. Properties Button 3

Properties Value
Name
Name Button3
Text Exclamation Message

Properties Button 4

Klik pada tombol 4, kemudian atur properties-nya seperti tabel 5.

Tabel 5. Properties Button 4

Properties Value
Name
Name Button4
Text Information Message

Properties Button 5

Klik pada tombol 5, kemudian atur properties-nya seperti tabel 6.

Tabel 6. Properties Button 5

Properties Value
Name
Name Button5
Text Critical Message

3
http://purnamayasa.wordpress.com © 2011 oleh I Made Purnama Yasa

Properties Button 6

Klik pada tombol 6, kemudian atur properties-nya seperti tabel 7.

Tabel 7. Properties Button 6

Properties Value
Name
Name Button6
Text Exclamation Message

 Properties Group Box

1 2

Properties Group Box 1

Klik pada Group Box 1, kemudian atur properties-nya seperti tabel 8.

Tabel 8. Properties Group Box 1

Properties Value
Name
Name GroupBox1
Text Standard Message

Properties Group Box 2

Klik pada Group Box 2, kemudian atur properties-nya seperti tabel 9.

Tabel 9. Properties Group Box 2

Properties Value
Name
Name GroupBox2
Text Yes No Message

Kode Program

Berikurt ini adalah kode programnya

4
http://purnamayasa.wordpress.com © 2011 oleh I Made Purnama Yasa

' I Made Purnama Yasa


' 17/04/2011
'
' http://purnamayasa.wordpress.com

Public Class frmMain

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
MsgBox("This is Information Message Box", MsgBoxStyle.Information, "Information
Message")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
MsgBox("This is Critical Message Box", MsgBoxStyle.Critical, "Critical Message")
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
MsgBox("This is Exclamation Message Box", MsgBoxStyle.Exclamation,
"Exclamation Message")
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
Dim strMsg As String

strMsg = "This is Information Message Box"

If MsgBox(strMsg, MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Information


Message") = MsgBoxResult.Yes Then
MsgBox("You choose Yes", MsgBoxStyle.Information, "Yes")
Else
MsgBox("You choose No", MsgBoxStyle.Information, "No")
End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
Dim strMsg As String

strMsg = "This is Critical Message Box"

If MsgBox(strMsg, MsgBoxStyle.Critical + MsgBoxStyle.YesNo, "Critical Message")


= MsgBoxResult.Yes Then
MsgBox("You choose Yes", MsgBoxStyle.Critical, "Yes")
Else
MsgBox("You choose No", MsgBoxStyle.Critical, "No")
End If
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
Dim strMsg As String

strMsg = "This is Exclamation Message Box"

5
http://purnamayasa.wordpress.com © 2011 oleh I Made Purnama Yasa

If MsgBox(strMsg, MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "Exclamation


Message") = MsgBoxResult.Yes Then
MsgBox("You choose Yes", MsgBoxStyle.Exclamation, "Yes")
Else
MsgBox("You choose No", MsgBoxStyle.Exclamation, "No")
End If
End Sub
End Class

You might also like