none
Messagebox comes up twice and empty textbox gives error

    Question

  • Thanks for your time on reading this.

    My problem is that if i use texbox.Clear(); that the messagebox shows 2 times.

    Here is my code:

                    

       private void textBox3_TextChanged(object sender, EventArgs e)
            {
                int val = 0;
                bool res = Int32.TryParse(textBox3.Text, out val);
                if (res == true && val > -1 && val < 101)
                {
                    // add record
                }
                else
                {
                    textBox3.Clear();
                    MessageBox.Show("Please input 0 to 100 only.");
                    return;


                }


            } 

    AND

    if i use this:

       if (textBox3.Text == "")
                {
                    MessageBox.Show("Vul aub iets in", "Lege invoer",
        MessageBoxButtons.OK, MessageBoxIcon.Warning);

                }

    Then i will get a System.FormatException error for using this " straal = int.Parse(textBox3.Text);"

    ALSO

    When i am in the textbox and i enter a number and enter backspace the alert comes up

    Monday, May 7, 2018 8:38 PM