Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function to validate string for numeric with decimal point
#1
Write a bulletproof function to validate a user input string that must be:
* Strictly numeric, unsigned, no leading/trailing/embedded blanks.
* But may contain a decimal point. The number of decimal places that the number can contain is a specification for the input field.
* Cannot be null, obviously.

Example: FUNCTION NUMDECIMAL (userinput$, numdecimals)
Where:
userinput$ is the string input by the user.
numdecimals is a value of 0 to n, where n is the maximum number of decimal places allowed for this field. Numdecimals may be zero.

The NUMDECIMAL function returns -1 if valid field, or 0 if invalid.

Remember that users are likely to input all kinds of garbage, including numbers with 2 decimal points, like 123.45.67

P.S. Your posted programs will be tested.
*****
Reply


Messages In This Thread
Function to validate string for numeric with decimal point - by Moneo - 07-09-2003, 06:18 AM
To WhiteTiger, Nathan, Agamemnus: - by Moneo - 07-09-2003, 10:28 PM
ah, young one - by Agamemnus - 07-11-2003, 07:08 AM
Re: ah, young one - by oracle - 07-11-2003, 07:13 AM
well..... - by Agamemnus - 07-12-2003, 07:15 AM
Re: well..... - by Moneo - 07-13-2003, 04:59 AM
programming help - by Agamemnus - 07-13-2003, 04:47 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)