VB.Net/GUI/MessageBox
Содержание
MessageBox: Abort, Retry and Ignore
Imports System
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Configuration
Imports System.Resources
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.IO
Imports System.Drawing.Printing
Public Class MainClass
Shared Sub Main()
Dim intResult As DialogResult
"Get the results of the button clicked
intResult = MessageBox.Show("The A drive is not ready." & _
ControlChars.CrLf & ControlChars.CrLf & _
"Please insert a diskette into the drive.", "Device Not Ready", _
MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button2)
"Process the results of the button clicked
Select Case intResult
Case DialogResult.Abort
"Do abort processing here...
System.Console.WriteLine("Abort Clicked")
Case DialogResult.Retry
"Do retry processing here...
System.Console.WriteLine("Retry Clicked")
Case DialogResult.Ignore
"Do ignore processing here...
System.Console.WriteLine("Ignore Clicked")
End Select
End Sub
End Class
Message Box: Abort Retry Ignore
Imports System
Imports System.Drawing
Imports System.Data
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
Imports System.Drawing.Printing
Public Class MainClass
Shared Sub Main()
Dim intResult As Integer
intResult = MessageBox.Show("The A drive is not ready." & _
vbCrLf & vbCrLf & _
"Please insert a diskette into the drive.", _
"Device Not Ready", _
MessageBoxButtons.AbortRetryIgnore, _
MessageBoxIcon.Error, _
MessageBoxDefaultButton.Button2)
If intResult = DialogResult.Abort Then
" Do abort processing here...
Console.WriteLine( "Abort Clicked")
ElseIf intResult = DialogResult.Retry Then
" Do retry processing here...
Console.WriteLine("Retry Clicked")
Else "It has to be ignore
" Do ignore processing here...
Console.WriteLine("Ignore Clicked")
End If
End Sub
End Class
Message box Demo
Imports System
Imports System.Windows.Forms
Class MyFirstForm
Inherits Form
Private WithEvents mybutton As Button
Public Sub New()
Me.Text = "Hello, WinForms!"
mybutton = New Button()
mybutton.Text = "Click Me!"
Me.Controls.Add(mybutton)
End Sub
Public Sub mybutton_Click(sender As Object, e As EventArgs) Handles mybutton.Click
MessageBox.Show("Message")
End Sub
Shared Sub Main()
Dim myform As Form = New MyFirstForm()
Application.Run(myform)
End Sub
End Class
MessageBox: OK or Cancel
Imports System
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Configuration
Imports System.Resources
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.IO
Imports System.Drawing.Printing
Public Class MainClass
Shared Sub Main()
If MessageBox.Show("Info Text.","Title", MessageBoxButtons.OKCancel, _
Nothing, MessageBoxDefaultButton.Button1) = DialogResult.OK Then
System.Console.WriteLine("OK Clicked")
Else
System.Console.WriteLine("Cancel Clicked")
End If
End Sub
End Class