Maybe this will work for you.
Here is a simple Windows Form Application.
On my form I have 3 elements:
1) a Textbox named textbox1
2) a Label named label1
3) a Button named Button1
Below shows how I setup the textbox1.TextChanged and button1_click.
As you enter text into the textbox, the label will show how many characters are in the textbox. If you backspace or delete any, the count will change.
If the count does not = 6 when you click the button, it does NOTHING.
However, if it DOES = 6, then it changes the label to say "OK"
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
label1.Text = textBox1.TextLength.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if (Convert.ToInt32(label1.Text) != 6)
{
}
else
{
label1.Text = "OK";
}
}
}
}
Hope this helps!