Sunday, April 6, 2014

Visual Basic Tutorial : How to Add Msgbox/Messagebox in vb.net



In this tutorial we are going to add a message box in our projects. The function of message box is a bride between the user and the program, with the use of message box the program and user can interact to each other to do some specific commands and actions..

There are several types of message box you can use in visual basic.

This tutorial will require you an "if Statement"

Using this statement it will allow you to interact with your program easily.. The message box can be displayed as follows:

The normal "msgbox" can display style like these:

According to support.microsoft.com


Member name
Description
AbortRetryIgnore
AbortRetry, and Ignore buttons. 
This member is equivalent 
to the Visual Basic constant 
vbAbortRetryIgnore.
ApplicationModal
Application modal message box. 
This member is equivalent to 
the Visual Basic constant 
vbApplicationModal.
Critical
Critical message. 
This member is equivalent 
to the Visual Basic 
constant 
vbCritical.
DefaultButton1
First button is default. 
This member is equivalent 
to the Visual Basic constant 
vbDefaultButton1.
DefaultButton2
Second button is default. 
This member is equivalent 
to the Visual Basic constant 
vbDefaultButton2.
DefaultButton3
Third button is default. 
This member is equivalent 
to the Visual Basic constant 
vbDefaultButton3.
Exclamation
Warning message. 
This member is equivalent to 
the Visual Basic 
constant 
vbExclamation.
Information
Information message. 
This member is equivalent 
to the Visual Basic constant 
vbInformation.
MsgBoxHelp
Help text. This member 
is equivalent to the Visual Basic constant
vbMsgBoxHelp.
MsgBoxRight
Right-aligned text. 
This member is equivalent 
to the Visual Basic constant 
vbMsgBoxRight.
MsgBoxRtlReading
Right-to-left reading 
text (Hebrew and Arabic 
systems). This member is 
equivalent to the Visual Basic constant 
vbMsgBoxRtlReading.
MsgBoxSetForeground
Foreground message box window. 
This member is equivalent 
to the Visual Basic constant 
vbMsgBoxSetForeground.
OkCancel
OK and Cancel buttons. 
This member is equivalent 
to the Visual Basic 
constant 
vbOKCancel.
OkOnly
OK button only (default). 
This member is equivalent 
to the Visual Basic constant 
vbOKOnly.
Question
Warning query. This member 
is equivalent to the 
Visual Basic constant
vbQuestion.
RetryCancel
Retry and Cancel buttons. 
This member is equivalent 
to the Visual Basic constant 
vbRetryCancel.
SystemModal
System modal message box. 
This member is equivalent 
to the Visual Basic constant 
vbSystemModal.
YesNo
Yes and No buttons. 
This member is equivalent 
to the Visual Basic constant 
vbYesNo.
YesNoCancel

YesNo, and Cancel buttons. 
This member is equivalent 
to the Visual Basic constant 
vbYesNoCancel.

This are the basic codes on how to use msgbox in your project. this code will not require to use the if statement or optional.. this type of message box is for notification only..

Here's the code

Msgbox("Your Message here", Msgbox.style here, "msgbox title")
Try to put this message box into the button_click event to notify you or other users about the action performed..

Learn How to Add Advance Message Box in vb.net

No comments:

Post a Comment