From the few code you have posted, it is difficult to know exactly where the error comes. As I can see your "Year" is a String, so you are probably converting it to int when entered, so you can validate with your range.
Some possiblities that I can imagine:
- If the string is empty, the conversion to number might return a error code that you anyways evaluate and it is out of your range
- The variable you are using to hold the converted "year" is already having a value (probably 0), when the conversion of the string is not successful, the variable remains with initialized value, and that value is out of your range triggering the wrong error message.
Since you are not giving more information about your code, it is difficult to know where the error is.
Please have a look to
http://msdn.microsoft.com/en-us/library/vstudio/sf1aw27b(v=vs.110).aspx[
^]. It might give you a possible approach to (at least) have a better error handling