【VISUAL VB.NET】Message Boxes

 Imports System

Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Linq Imports System.Text Imports System.Threading.Tasks Imports System.Windows.Forms ' make sure that using System.Diagnostics; is included Imports System.Diagnostics ' make sure that using System.Security.Principal; is included Imports System.Security.Principal Public Class Form1 Public Sub New() MyBase.New() InitializeComponent() End Sub #Region "basic function for app" Private Sub lblLink_Click_1(sender As Object, e As EventArgs) Handles lblLink.Click Process.Start("www.vclexamples.com") End Sub Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean If (keyData = Keys.Escape) Then Me.Close() Return True End If Return MyBase.ProcessCmdKey(msg, keyData) End Function #End Region Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click For Each item As String In comboBox1.Items If comboBox1.SelectedIndex = 0 Then ' no icon MessageBox.Show(textBox1.Text, "MessageBox", MessageBoxButtons.OK) Exit For End If If comboBox1.SelectedIndex = 1 Then ' info icon ... MessageBox.Show(textBox1.Text, "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Information) Exit For End If If comboBox1.SelectedIndex = 2 Then ' question icon MessageBox.Show(textBox1.Text, "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Question) Exit For End If If comboBox1.SelectedIndex = 3 Then ' warning icon MessageBox.Show(textBox1.Text, "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Warning) Exit For End If If comboBox1.SelectedIndex = 4 Then ' error icon MessageBox.Show(textBox1.Text, "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.[Error]) Exit For End If Next End Sub Private Sub button2_Click(sender As Object, e As EventArgs) Handles button2.Click Dim d As DialogResult = MessageBox.Show("Choose Yes or No", "MsgBox result", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If d = DialogResult.Yes Then MessageBox.Show("Your choice: YES", "MessageBoxExample", MessageBoxButtons.OK, MessageBoxIcon.Question) End If If d = DialogResult.No Then MessageBox.Show("Your choice: NO", "MessageBoxExample", MessageBoxButtons.OK, MessageBoxIcon.Question) End If End Sub End Class

No comments:

Antisemitism, pt. 1

This was originally intended to be a short jotting down of some off-the-cuff thoughts about antisemitism. I don’t know what possessed me to ...

Contact Form

Name

Email *

Message *