VB.Net - Syntax


Dim oResult As System.Windows.Forms.DialogResult 
oResult = Windows.Forms.MessageBox.Show("This is a question ?",
                                        "Message Box Caption", _
                                        Windows.Forms.MessageBoxButtons.YesNo
If (oResult = Windows.Forms.DialogResult.No) Then
End If

The result is passed back as a DialogResult enumerated value


Microsoft.VisualBasic.MsgBox

Microsoft.VisualBasic.MsgBox(prompt As Object, _ 
                          [ buttons As Microsoft.VisualBasic.MsgBoxStyle = MsgBoxStyle.OKOnly ], _
                            [ title As Object = Nothing ], _
                                    As Microsoft.VisualBasic.MsgBoxResult

When you have a look inside it is easy to see which method should be used to display a message box.
It appears that Microsoft.VisualBasic.MsgBox() does some exception check and then passes the call onto System.Windows.Forms.MessageBox.Show() this then does pretty much the same exception checking and the passes the call onto System.Windows.Forms.SafeNativeMethods.MessageBox() which is itself a wrapper for a win32 API call to user32.dll.


Microsoft.VisualBasic.MsgBoxStyle 

Microsoft.VisualBasic.Interaction.MsgBox() 

VB.NetC#
OKOnlyMessageBoxButtons.OK
OKCancelMessageBoxButtons.OKCancel
AbortRetryIgnoreMessageBoxButtons.OKAbortRetryIgnore
YesNoCancelMessageBoxButtons.YesNoCancel
YesNoMessageBoxButtons.YesNo
RetryCancelMessageBoxButtons.RetryCancel
CriticalMessageBoxIcon.Error
QuestionMessageBoxIcon.Question
ExclamationMessageBoxIcon.Exclamation
InformationMessageBoxIcon.Information
DefaultButton1MessageBoxDefaultButton.Bullet1


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext