VB.Net Tutorial/GUI/MsgBox
Содержание
MsgBox and vbYes
<source lang="vbnet">Imports System.Windows.Forms public class MsgBoxDemo
public Shared Sub Main Dim exita As String exita = MsgBox("Exit?", Microsoft.VisualBasic.MsgBoxStyle.Exclamation + Microsoft.VisualBasic.MsgBoxStyle.YesNo + Microsoft.VisualBasic.MsgBoxStyle.MsgBoxHelp, "Title") If exita = vbYes Then End End If Console.WriteLine( Microsoft.VisualBasic.MsgBoxStyle.MsgBoxHelp) End Sub
End class</source>
MsgBox with only message
<source lang="vbnet">Module Module1
Sub Main() MsgBox("Message") End Sub
End Module</source>
MsgBox with title and Abort Retry Ignore buttons
<source lang="vbnet">Module Module1
Sub Main() MsgBox("Message", MsgBoxStyle.AbortRetryIgnore,"Title") End Sub
End Module</source>
Return value from MsgBox
<source lang="vbnet">Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class MsgBoxReturnValue
public Shared Sub Main Dim intReturnValue As Integer intReturnValue = MsgBox("This is a message box!",MsgBoxStyle.OKCancel + MsgBoxStyle.Information + MsgBoxStyle.SystemModal, "Message Box") If (intReturnValue = MsgBoxResult.OK) Then Console.WriteLine("You clicked the OK button.") End If End Sub
End class</source>
Set MsgBox Button combination
<source lang="vbnet">Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class MsgBoxButtonSetting
public Shared Sub Main
Dim Areturn As String Areturn = MsgBox("Message", vbOKCancel + vbDefaultButton1 + vbQuestion, "Title") "vbOKOnly + vbInformation + vbDefaultButton1 "vbOKOnly + vbExclamation + vbDefaultButton1 "vbOKOnly + vbDefaultButton1 + vbCritical Select Case Areturn Case vbOK Console.WriteLine("vbOK") Case vbCancel Console.WriteLine("vbCancel") Case vbAbort Console.WriteLine("vbAbort") Case vbRetry Console.WriteLine("vbRetry") Case vbIgnore Console.WriteLine("vbIgnore") Case Else Console.WriteLine("Else") End Select End Sub
End class</source>