0

Newbie here, whenever I dont input/input letter then click next button I get this error[System.FormatException: 'Input string was not in a correct format.' ] I dont know what to do. I just follow the instructionenter image description hereenter image description here

Im expecting whenever I clicked Nextbutton, I dont get that error.

3
  • Welcome to Stack Overflow! 1) Please do not upload images of code/errors when asking a question. 2) The error means that the value in the TextBox cannot be converted to an int. Consider using int.TryParse() instead of Convert.ToInt32(). Commented Oct 28, 2022 at 9:14
  • 1
    Does this answer your question? Not able to cast string to int. Error msg: Input string was not in a correct format Commented Oct 28, 2022 at 9:16
  • If you don't enter anything in the textbox, that mean it is an empty string. Empty string can not be converted to a number, that's why you are getting this error. If you don't expect and empty string then you should put a check if(!string.IsNullOrEmpty(txtStudentNo.Text)) before converting it to a number. Commented Oct 28, 2022 at 9:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.