Use App.config to assign the value for non fixed length
<configuration>
<appSettings>
<add key ="MaxLength" value = "7"/>
</appSettings>
</configuration>
Fetch the value using the following code
int maxLength = ConfigurationSettings.AppSettings [ "MaxLength" ] ;
Use it in functionality
if (textBox1.Text.Length == maxLength)
{
string x=textbox1.Text;
textBox1.Clear();
MessageBox.Show(x);
}
Post back for more queries :)
Rgds / GV