VB.Net Tutorial/GUI/MsgBox — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 16:40, 26 мая 2010

MsgBox and vbYes

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

MsgBox with only message

Module Module1
    Sub Main()
        MsgBox("Message")
    End Sub
End Module

MsgBox with title and Abort Retry Ignore buttons

Module Module1
    Sub Main()
        MsgBox("Message", MsgBoxStyle.AbortRetryIgnore,"Title")
    End Sub
End Module

Return value from MsgBox

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

Set MsgBox Button combination

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