Reading integer values from a textbox in visual C# 2008

Jan 11 2009 5:38 PM
Hi,
I'm a newbie in visual C# and i need to read values from a textbox into an integer variable.
The user is not allowed to input other characters but numbers into the textbox.

            int a1;
            string ia1;
            ia1 = txtMNA1.Text.ToString();
            a1 = Convert.ToInt32(ia1);

This is what i wrote and it returns "Input string was not in a correct format." runtime error.

Thanks for your help,
Hristo

Answers (1)