how to restrict if the text box value is more than 100
  • hi buddies  I have a doubt.
    How to restrict the textbox1 value .
    if the textbox. text is more than 100 means 
    i have to restrict . Plz help me 
  • 4 Comments sorted by
  • Vote Up0Vote Down Akwin_LopezAkwin_Lopez
    102.00 Karma Accepted Answer
     At finally i got the answer

     int value;
                bool isConverted = Int32.TryParse(textbox.Text.Trim(), out value);
                if (!isConverted)
                {
                    MessageBox.Show("Only numbers allowed");
                    return;
                }

                if (value < 1 || value > 24)
                {
                    MessageBox.Show("Please enter a value between 1-24");
                }
    i hope its also right one

  • There is a built in function in winform Textbox.Maxlength
    or if you are using asp.net there is a html attribute maxlength
  • @atrinaveed

    Maxlength is used for textbox's maximum character length not for validation like @Akwin_Lopez asked.
  • Vote Up0Vote Down Akwin_LopezAkwin_Lopez
    102.00 Karma Accepted Answer
      int value;
                bool con = false;
                con = Int32.TryParse(textBox1.Text.Trim(), out value);
                if (value > 100)
                {
                    MessageBox.Show("Please enter a value between 1-100");
                }

    i got a code thank you both of you 

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

Top Posters Weekly

Optimum Creative