to close a application
hi friends..
my query is in windows apllication..
i enter a particular text into textbox first time during run time it will give a warning message...
ex.textbox1.text=hi
second time i enter the same text to that textbox (hi)means it will give a message and the system will be logoff ( if i enter the same text during second time...)
i need coding for that in vb or c#..
regards
gopal
Satish KathiPosted Nov 26, 2008, 2:48 PM
public partial class Form4 : Form
{
//Variable to hold the number of times user entered text "Hi"
private int errorCount = 0;
public Form4()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//Chech if user has entered "Hi"
if (textBox1.Text == "Hi")
{
//If user eneterd "Hi" first time
if (errorCount < 1)
{
//display Error Message
MessageBox.Show("textBox1.Text = Hi", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//Increment error count
errorCount++;
}
//If user has entered "Hi" more than one time
else
{
//Close the application
this.Close();
}
}
}
}