Option Explicit On 
Option Strict On

Public Class frmMessageBox
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents grpButtons As System.Windows.Forms.GroupBox
  Friend WithEvents rdoOK As System.Windows.Forms.RadioButton
  Friend WithEvents rdoOKCancel As System.Windows.Forms.RadioButton
  Friend WithEvents rdoYesNoCancel As System.Windows.Forms.RadioButton
  Friend WithEvents rdoYesNo As System.Windows.Forms.RadioButton
  Friend WithEvents rdoRetryCancel As System.Windows.Forms.RadioButton
  Friend WithEvents grpIcon As System.Windows.Forms.GroupBox
  Friend WithEvents CheckedListBox1 As System.Windows.Forms.CheckedListBox
  Friend WithEvents rdoNone As System.Windows.Forms.RadioButton
  Friend WithEvents rdoExclamation As System.Windows.Forms.RadioButton
  Friend WithEvents rdoError As System.Windows.Forms.RadioButton
  Friend WithEvents rdoInformation As System.Windows.Forms.RadioButton
  Friend WithEvents grpDefault As System.Windows.Forms.GroupBox
        Friend WithEvents grpMessage As System.Windows.Forms.GroupBox
  Friend WithEvents txtMessage As System.Windows.Forms.TextBox
  Friend WithEvents btnShow As System.Windows.Forms.Button
  Friend WithEvents rdoAbortRetryIgnore As System.Windows.Forms.RadioButton
  Friend WithEvents rdoQuestion As System.Windows.Forms.RadioButton
  Friend WithEvents rdoDefaultButton3 As System.Windows.Forms.RadioButton
  Friend WithEvents rdoDefaultButton2 As System.Windows.Forms.RadioButton
  Friend WithEvents rdoDefaultButton1 As System.Windows.Forms.RadioButton

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.rdoDefaultButton1 = New System.Windows.Forms.RadioButton()
    Me.grpDefault = New System.Windows.Forms.GroupBox()
    Me.rdoDefaultButton3 = New System.Windows.Forms.RadioButton()
    Me.rdoDefaultButton2 = New System.Windows.Forms.RadioButton()
    Me.rdoYesNoCancel = New System.Windows.Forms.RadioButton()
    Me.rdoExclamation = New System.Windows.Forms.RadioButton()
    Me.grpButtons = New System.Windows.Forms.GroupBox()
    Me.rdoRetryCancel = New System.Windows.Forms.RadioButton()
    Me.rdoYesNo = New System.Windows.Forms.RadioButton()
    Me.rdoAbortRetryIgnore = New System.Windows.Forms.RadioButton()
    Me.rdoOKCancel = New System.Windows.Forms.RadioButton()
    Me.rdoOK = New System.Windows.Forms.RadioButton()
    Me.rdoInformation = New System.Windows.Forms.RadioButton()
    Me.grpIcon = New System.Windows.Forms.GroupBox()
    Me.rdoError = New System.Windows.Forms.RadioButton()
    Me.rdoNone = New System.Windows.Forms.RadioButton()
    Me.rdoQuestion = New System.Windows.Forms.RadioButton()
    Me.btnShow = New System.Windows.Forms.Button()
    Me.grpMessage = New System.Windows.Forms.GroupBox()
    Me.txtMessage = New System.Windows.Forms.TextBox()
    Me.grpDefault.SuspendLayout()
    Me.grpButtons.SuspendLayout()
    Me.grpIcon.SuspendLayout()
    Me.grpMessage.SuspendLayout()
    Me.SuspendLayout()
    '
    'rdoDefaultButton1
    '
    Me.rdoDefaultButton1.Location = New System.Drawing.Point(16, 24)
    Me.rdoDefaultButton1.Name = "rdoDefaultButton1"
    Me.rdoDefaultButton1.TabIndex = 1
    Me.rdoDefaultButton1.Text = "Button 1"
    '
    'grpDefault
    '
    Me.grpDefault.Controls.AddRange(New System.Windows.Forms.Control() {Me.rdoDefaultButton3, Me.rdoDefaultButton2, Me.rdoDefaultButton1})
    Me.grpDefault.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.grpDefault.Location = New System.Drawing.Point(8, 192)
    Me.grpDefault.Name = "grpDefault"
    Me.grpDefault.Size = New System.Drawing.Size(144, 104)
    Me.grpDefault.TabIndex = 0
    Me.grpDefault.TabStop = False
    Me.grpDefault.Text = "Default Button"
    '
    'rdoDefaultButton3
    '
    Me.rdoDefaultButton3.Location = New System.Drawing.Point(16, 72)
    Me.rdoDefaultButton3.Name = "rdoDefaultButton3"
    Me.rdoDefaultButton3.TabIndex = 1
    Me.rdoDefaultButton3.Text = "Button 3"
    '
    'rdoDefaultButton2
    '
    Me.rdoDefaultButton2.Location = New System.Drawing.Point(16, 48)
    Me.rdoDefaultButton2.Name = "rdoDefaultButton2"
    Me.rdoDefaultButton2.TabIndex = 1
    Me.rdoDefaultButton2.Text = "Button 2"
    '
    'rdoYesNoCancel
    '
    Me.rdoYesNoCancel.Location = New System.Drawing.Point(16, 96)
    Me.rdoYesNoCancel.Name = "rdoYesNoCancel"
    Me.rdoYesNoCancel.TabIndex = 1
    Me.rdoYesNoCancel.Text = "Yes/No/Cancel"
    '
    'rdoExclamation
    '
    Me.rdoExclamation.Location = New System.Drawing.Point(16, 72)
    Me.rdoExclamation.Name = "rdoExclamation"
    Me.rdoExclamation.TabIndex = 1
    Me.rdoExclamation.Text = "Exclamation"
    '
    'grpButtons
    '
    Me.grpButtons.Controls.AddRange(New System.Windows.Forms.Control() {Me.rdoRetryCancel, Me.rdoYesNo, Me.rdoYesNoCancel, Me.rdoAbortRetryIgnore, Me.rdoOKCancel, Me.rdoOK})
    Me.grpButtons.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.grpButtons.Location = New System.Drawing.Point(8, 8)
    Me.grpButtons.Name = "grpButtons"
    Me.grpButtons.Size = New System.Drawing.Size(144, 176)
    Me.grpButtons.TabIndex = 0
    Me.grpButtons.TabStop = False
    Me.grpButtons.Text = "Button(s)"
    '
    'rdoRetryCancel
    '
    Me.rdoRetryCancel.Location = New System.Drawing.Point(16, 144)
    Me.rdoRetryCancel.Name = "rdoRetryCancel"
    Me.rdoRetryCancel.TabIndex = 1
    Me.rdoRetryCancel.Text = "Retry/Cancel"
    '
    'rdoYesNo
    '
    Me.rdoYesNo.Location = New System.Drawing.Point(16, 120)
    Me.rdoYesNo.Name = "rdoYesNo"
    Me.rdoYesNo.TabIndex = 1
    Me.rdoYesNo.Text = "Yes/No"
    '
    'rdoAbortRetryIgnore
    '
    Me.rdoAbortRetryIgnore.Location = New System.Drawing.Point(16, 72)
    Me.rdoAbortRetryIgnore.Name = "rdoAbortRetryIgnore"
    Me.rdoAbortRetryIgnore.Size = New System.Drawing.Size(120, 24)
    Me.rdoAbortRetryIgnore.TabIndex = 1
    Me.rdoAbortRetryIgnore.Text = "Abort/Retry/Ignore"
    '
    'rdoOKCancel
    '
    Me.rdoOKCancel.Location = New System.Drawing.Point(16, 48)
    Me.rdoOKCancel.Name = "rdoOKCancel"
    Me.rdoOKCancel.TabIndex = 1
    Me.rdoOKCancel.Text = "OK/Cancel"
    '
    'rdoOK
    '
    Me.rdoOK.Location = New System.Drawing.Point(16, 24)
    Me.rdoOK.Name = "rdoOK"
    Me.rdoOK.TabIndex = 1
    Me.rdoOK.Text = "OK only"
    '
    'rdoInformation
    '
    Me.rdoInformation.Location = New System.Drawing.Point(16, 96)
    Me.rdoInformation.Name = "rdoInformation"
    Me.rdoInformation.TabIndex = 1
    Me.rdoInformation.Text = "Information"
    '
    'grpIcon
    '
    Me.grpIcon.Controls.AddRange(New System.Windows.Forms.Control() {Me.rdoError, Me.rdoInformation, Me.rdoExclamation, Me.rdoNone, Me.rdoQuestion})
    Me.grpIcon.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.grpIcon.Location = New System.Drawing.Point(176, 8)
    Me.grpIcon.Name = "grpIcon"
    Me.grpIcon.Size = New System.Drawing.Size(128, 160)
    Me.grpIcon.TabIndex = 0
    Me.grpIcon.TabStop = False
    Me.grpIcon.Text = "Icon"
    '
    'rdoError
    '
    Me.rdoError.Location = New System.Drawing.Point(16, 48)
    Me.rdoError.Name = "rdoError"
    Me.rdoError.TabIndex = 1
    Me.rdoError.Text = "Error"
    '
    'rdoNone
    '
    Me.rdoNone.Location = New System.Drawing.Point(16, 24)
    Me.rdoNone.Name = "rdoNone"
    Me.rdoNone.TabIndex = 1
    Me.rdoNone.Text = "None"
    '
    'rdoQuestion
    '
    Me.rdoQuestion.Location = New System.Drawing.Point(16, 120)
    Me.rdoQuestion.Name = "rdoQuestion"
    Me.rdoQuestion.TabIndex = 1
    Me.rdoQuestion.Text = "Question"
    '
    'btnShow
    '
    Me.btnShow.Location = New System.Drawing.Point(8, 304)
    Me.btnShow.Name = "btnShow"
    Me.btnShow.Size = New System.Drawing.Size(144, 32)
    Me.btnShow.TabIndex = 3
    Me.btnShow.Text = "&Show Message Box"
    '
    'grpMessage
    '
    Me.grpMessage.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtMessage})
    Me.grpMessage.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.grpMessage.Location = New System.Drawing.Point(160, 176)
    Me.grpMessage.Name = "grpMessage"
    Me.grpMessage.Size = New System.Drawing.Size(160, 152)
    Me.grpMessage.TabIndex = 1
    Me.grpMessage.TabStop = False
    Me.grpMessage.Text = "Message"
    '
    'txtMessage
    '
    Me.txtMessage.Location = New System.Drawing.Point(8, 24)
    Me.txtMessage.Multiline = True
    Me.txtMessage.Name = "txtMessage"
    Me.txtMessage.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
    Me.txtMessage.Size = New System.Drawing.Size(144, 120)
    Me.txtMessage.TabIndex = 0
    Me.txtMessage.Text = ""
    '
    'frmMessageBox
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(6, 13)
    Me.ClientSize = New System.Drawing.Size(334, 347)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnShow, Me.grpMessage, Me.grpDefault, Me.grpIcon, Me.grpButtons})
    Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
    Me.Name = "frmMessageBox"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Message Box Problem"
    Me.grpDefault.ResumeLayout(False)
    Me.grpButtons.ResumeLayout(False)
    Me.grpIcon.ResumeLayout(False)
    Me.grpMessage.ResumeLayout(False)
    Me.ResumeLayout(False)

  End Sub

#End Region

  Dim ButtonType As MessageBoxButtons
  Dim ButtonDefault As MessageBoxDefaultButton
  Dim IconType As MessageBoxIcon

  Private Sub frmMessageBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'click on radio buttons to initialize values
    rdoOK.PerformClick()
    rdoDefaultButton1.PerformClick()
    rdoNone.PerformClick()
  End Sub

  Private Sub rdoButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoOK.CheckedChanged, rdoOKCancel.CheckedChanged, rdoAbortRetryIgnore.CheckedChanged, rdoYesNoCancel.CheckedChanged, rdoYesNo.CheckedChanged, rdoRetryCancel.CheckedChanged
    Dim rdoButton As RadioButton
    rdoButton = CType(sender, RadioButton)
    Select Case rdoButton.Name
      Case "rdoOK"
        ButtonType = MessageBoxButtons.OK
      Case "rdoOKCancel"
        ButtonType = MessageBoxButtons.OKCancel
      Case "rdoAbortRetryIgnore"
        ButtonType = MessageBoxButtons.AbortRetryIgnore
      Case "rdoYesNoCancel"
        ButtonType = MessageBoxButtons.YesNoCancel
      Case "rdoYesNo"
        ButtonType = MessageBoxButtons.YesNo
      Case "rdoRetryCancel"
        ButtonType = MessageBoxButtons.RetryCancel
    End Select
  End Sub

  Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
    'display message box
    Dim Rtn As DialogResult
    Dim Message As String
    Rtn = MessageBox.Show(txtMessage.Text, "Message Box Example", ButtonType, IconType, ButtonDefault)
    Select Case Rtn
      Case DialogResult.OK
        Message = "OK"
      Case DialogResult.Cancel
        Message = "Cancel"
      Case DialogResult.Abort
        Message = "Abort"
      Case DialogResult.Retry
        Message = "Retry"
      Case DialogResult.Ignore
        Message = "Ignore"
      Case DialogResult.Yes
        Message = "Yes"
      Case DialogResult.No
        Message = "No"
    End Select
    MessageBox.Show(Message + " Clicked", "Message Box Results", MessageBoxButtons.OK)
  End Sub


  Private Sub rdoDefault_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoDefaultButton1.CheckedChanged, rdoDefaultButton2.CheckedChanged, rdoDefaultButton3.CheckedChanged
    Dim rdoDefault As RadioButton
    rdoDefault = CType(sender, RadioButton)
    Select Case rdoDefault.Name
      Case "rdoButton1"
        ButtonDefault = MessageBoxDefaultButton.Button1
      Case "rdoButton2"
        ButtonDefault = MessageBoxDefaultButton.Button2
      Case "rdoButton3"
        ButtonDefault = MessageBoxDefaultButton.Button3
    End Select
  End Sub

  Private Sub rdoIcon_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdoNone.CheckedChanged, rdoError.CheckedChanged, rdoExclamation.CheckedChanged, rdoInformation.CheckedChanged, rdoQuestion.CheckedChanged
    Dim rdoIcon As RadioButton
    rdoIcon = CType(sender, RadioButton)
    Select Case rdoIcon.Name
      Case "rdoNone"
        IconType = MessageBoxIcon.None
      Case "rdoError"
        IconType = MessageBoxIcon.Error
      Case "rdoExclamation"
        IconType = MessageBoxIcon.Exclamation
      Case "rdoInformation"
        IconType = MessageBoxIcon.Information
      Case "rdoQuestion"
        IconType = MessageBoxIcon.Question
    End Select
  End Sub

End Class
