Input string was not in an incorrect format

Asked

Viewed 739 times

0

inserir a descrição da imagem aqui

I’m trying to create a geometric graph looking for a Txt file but when starting the application appears this error I’m half beginner and I’m having difficulties to find the solution

  • 1

    Post your code as text here and make sure you have detailed all that was necessary about the problem so that people can help you. I suggest starting by doing simple things, as you dominate, you get other more complicated things. Starting with complicated doesn’t learn anything.

2 answers

1

Your mistake is because you are trying to convert a nonexistent value to type INT, with this you get the error;

Run-time exception (line XXX): Input string was not in a correct format.
Stack Trace:

One way to fix this would be to see if it really is an int type value before converting, this can be done as follows.

int number;
bool result = Int32.TryParse(texto10, out number);

See more details here, commented lines is the example of your error.

0

check the contents of the string before converting it to Int32, the numeric format cannot contain spaces or commas, not even empty.

place a breakpoint on this line to check the value of the variable at the time of execution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.