On more then a few occasions questions have been raised in regards to MsgBox's , So, I fugure a MessageBox Tutorial is in order.
Code Snippets
Create a Standard MessageBox
Code:
MsgBox ("Your Message Here")
Or the one that is least known and least used
Code:
Interaction.MsgBox("Your Message Here")
Note: Both Work in the same capacity.
VB Abort, Retry , Cancel With Title
Code:
MsgBox("This is a messagebox with Abort, Retry Cancel, and You can set the Title of the messagebox", MsgBoxStyle.AbortRetryIgnore, "Title")
MsgBox and VbYes
Code:
Dim exitout As String
exitout = MsgBox("Would You Like To Exit?", Microsoft.VisualBasic.MsgBoxStyle.Exclamation + Microsoft.VisualBasic.MsgBoxStyle.YesNo + Microsoft.VisualBasic.MsgBoxStyle.MsgBoxHelp, "Title")
If exitout = vbYes Then
End
End If
Return a Value from msgbox
Code:
Dim ReturnV As Integer
ReturnV = MsgBox("This is a message box!",MsgBoxStyle.OKCancel + MsgBoxStyle******rmation + MsgBoxStyle.SystemModal, "Message Box")
If (ReturnV = MsgBoxResult.OK) Then
Label1.Text("OK button Has Been Clicked")
'Or use a messagebox, or a textbox or a listbox etc. etc. etc .
End If
Icons
You will notice in alot of these examples I am using the code
Code:
Microsoft.VisualBasic.MsgBoxStyle.Exclamation
This allows you to display the Microsoft message box icon/Style you would like to display
Here is the list of icons and style of MsgBox to display