MessageBox class In VB.NET 2005

Message boxes are often used objects. They are derived form Form Class, displayed modally and used to take user’s acknowledgement and also inform the user or alert the user of any thing that needs to be informed or alerted.


You cannot create a new instance of the System.Windows.Forms.MessageBox class. To display a message box, call the static method System.Windows.Forms.MessageBox.Show. The title, message, buttons, and icons displayed in the message box are determined by parameters that you pass to this method.


The following example shows how to use a System.Windows.Forms.MessageBox to inform the user of a missing entry in a System.Windows.Forms.TextBox.


This example assumes that the method is called from an existing form with a System.Windows.Forms.Button and a System.Windows.Forms.TextBox on it.


Protected Sub button1_Click(sender As Object, e As System.EventArgs)

If textBox1.Text = "" Then

MessageBox.Show("You must enter a name.", "Name Entry Error", _

MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

Else

' Code to act on the data entered would go here.

End If

End Sub



Questions by GeekAdmin   answers by GeekAdmin

Showing Answers 1 - 3 of 3 Answers

abru

  • Oct 11th, 2007
 

instead of writing
 
If textBox1.Text = "" Then

(which usually gives an error if ur textbox is set to receive numbers)


you can write

If textBox1.Text = String.Empty Then

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions