0 Members and 1 Guest are viewing this topic.
function CheckDigit(const Input: string): boolean;var i, len: integer; Ch: char;begin len:= length(Input); for i:= 1 to len do begin Ch:= Input[i]; if ((Ord(Ch) - 48 >= 0) and (Ord(Ch) - 48 <= 9)) then begin Result:= true; continue; end else begin if ((Ch = ' ') and (not(Result))) then begin continue; end else begin Result:= false; break; end; end; end;end;
To be honest are loops generally pretty slow, often slower than built in functions such as regexp. Also, you only test for 1-9, commas ans periods are also most often considered numeric. Dont forget spaces btw