Dhagaxtuur
Technical User
I need help validating entry of TEDIT->TEXT. How do I make sure user enters numbers with decimal points. Example: 29.95. If the user enters char, I want display error message or ignore it. Please help. Thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
int precision = 2;
int precision_count = 0;
bool stop = false;
void __fastcall Ttable::Edit2KeyPress(TObject *Sender, char &Key)
{
if (stop)
Key = 0;
else if(!strchr("0123456789.\r\n\x08",Key))
Key = 0;
else if (Key == '.')
{
if (precision_count == 0)
precision_count++;
else
Key = 0;
}
else if (precision_count > 0)
precision_count++;
if (precision_count == precision + 1)
stop = true;
}