public Speed() { InitializeComponent(); button1.Hide(); int getlen(TextBox t) => t.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Length; void setColors() { if (len1 != len) { label5.ForeColor = Color.Red; } else { label5.ForeColor = Color.Green; } if (len2 != len) { label6.ForeColor = Color.Red; } else { label6.ForeColor = Color.Green; } if (len > 0 && len == len1 && len == len2) { button1.Show(); } else { button1.Hide(); } } textBox1.TextChanged += (object o, EventArgs e) => { len = getlen(textBox1); label4.Text = len.ToString(); if (len == 0) { textBox3.Text = ""; } else { textBox3.Text = Expendator.Max(Expendator.Repeat(1, len), textBox3.Text.ToIntMas()).ToStringFromExp(); } setColors(); }; textBox2.TextChanged += (object o, EventArgs e) => { len1 = getlen(textBox2); label5.Text = len1.ToString(); setColors(); }; textBox3.TextChanged += (object o, EventArgs e) => { len2 = getlen(textBox3); label6.Text = len2.ToString(); setColors(); }; }