Thursday 24 September 2009

VB Message Box

VB Message Box

The VB Message Box must be one of the most frequently used modules in the Visual Basic library. The message box can be a very powerful tool and can help application users make the correct decision before proceeding with a choice.

To display a simple VB Message Box enter the following code:

Visual Basic 6
MsgBox ("This is a VB Message Box")

VB Message Box
Visual Basic.Net
MsgBox("This is a VB Message Box")

VB Message Box
There are various options available to you to enhance the appearance of a message box such as adding options of Yes, No and Cancel. Icons can be added to make the message box appear as a warning or a question. A title of the message box can also be specified. Here was chosen the title as 'Proceed?' and set the message box style as Question.

Visual Basic 6
MsgBox "Do you wish to proceed?", vbQuestion + vbYesNo, "Proceed?"

VB Message Box
Visual Basic.Net
MsgBox("Do you wish to proceed?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Proceed?")

VB Message Box
Here we have chosen an 'alert' style message box. It is informing the user that details cannot be displayed with an exclamation icon:

Visual Basic 6:
MsgBox "Cannot display details at this time", vbExclamation + vbOKOnly, "Details Unavailable"

VB Message Box
Visual Basic.Net
MsgBox("Cannot display details at this time", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation, "Details Unavailable")

VB Message Box

VB Message Box

No comments:

Post a Comment