Hello @quark, sorry for bothering again,

I wish to limit whatever the user input into a text field. In the attached image, I attempted to limit the user input of txt_defHPBS, which corresponds the field with the value 5.0.
Every time there is a change in the text field, I grab the string, convert it to a float and adjust it within the value range of 0 to 500, and set it back to display again. Initially, it worked fine, but after a few attempts where I randomly input something into the text field, the program crashes with the exception shown in the screenshot. It happens every time I try to run the sketch.
I was hoping that the user can only input integers or floats, within a range of 1 to 500. I have a feeling that might not be the best approach, what would be your advice? Thanks!