Solving the problem and re-testing the application

The problem comes from the conversion of the text field into a number. If the value inside the field is not a number, the program throws an exception. We can rewrite the code in order to fix this problem:

The code above catches the errors when working with numbers (it catches exceptions) and in case of an error it gives a value error in the field with the result . We start the program again with [Ctrl+F5] and try if it works. This time by entering a wrong number the result is error and the program doesn't break:

Is it complicated? It is normal to seem complex, of course. We are just beginning to get into programming. The example above requires much more knowledge and skills, which we are going to develop through this book and even afterwards. Just allow yourself to have some fun with desktop programming. If something doesn't work, watch the video in the beginning of this chapter or ask in the forum of SoftUni: https://softuni.bg/forum. Or move on bravely forward to the next example or to the next chapter of the book. A time will come when it is going to be easy for you, but you really have to put an effort and persistence. Programming is learnt slowly with lots and lots of practice.

results matching ""

    No results matching ""