Str2Single Function
Converts a string into a Single.

Unit
QESBPCSConvert

Declaration
Function Str2Single(const S: string): Single;

Description
Removes Thousand Separators if they are present as well as any leading or trailing white spaces (ie <= #32). If Number is Valid but out of Range then MaxSingle will be returned for a greater value and -MaxSingle for a lesser value. Non-numeric will return 0 unless you set ESBRaiseFloatError to true.

Also ignores Percentage Signs (%).

Parameters
the String to process

Category
String/Float Conversion Routines

Implementation

function Str2Single (const S: string): Single;
var
     X: Extended;
begin
     X := Str2Float (S);
     if X > MaxSingle then // Check with in boundaries
          Result := MaxSingle
     else if X < -MaxSingle then
          Result := -MaxSingle
     else
          Result := X; // Return Value
End;


HTML generated by Time2HELP
http://www.time2help.com