View Issue Details

IDProjectCategoryView StatusLast Update
0001597JEDI VCL00 JVCL Componentspublic2004-04-07 14:43
ReporteranonymousAssigned Touser72 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001597: Bug in TJvValidateEdit in latest CVS
DescriptionDesignTime:
Put an TJvValidateEdit component on a form. Set the DisplayType to dfFloat and try to enter an value like 1.55 or under Text 1.55 and you can see that its now 155. Why this happens? It's seems to happen with all float and/or currency values. DecimalPlaces = 2!

This seems to be a great bug, please help me out!

Thanks in advance!
TagsNo tags attached.

Activities

anonymous

2004-04-07 13:02

viewer   ~0003692

Hello everybody,

is there someone who can help me out with this really urgent problem? Please...

Thanks a lot!

user72

2004-04-07 13:07

  ~0003695

Last edited: 2004-04-07 13:18

The problem is actually in JvJCLUtils.StrToFloatDef. Change it to:

function StrToFloatDef(const Str: string; Def: Extended): Extended;
var
  lStr: string;
  i:integer;
begin
  lStr := '';
  for i := 1 to Length(Str) do
    if Str[i] in ['0'..'9','-','+', DecimalSeparator] then
      lStr := LStr + Str[i];
  Result := Def;
  if lStr <> '' then
  try
    { the string '-' fails StrToFloat, but it can be interpreted as 0 }
    if lStr[Length(lStr)] = '-' then
      lStr := lStr + '0';

    { a string that ends in a '.' such as '12.' fails StrToFloat,
     but as far as I am concerned, it may as well be interpreted as 12.0 }
    if lStr[Length(lStr)] = DecimalSeparator then
      lStr := lStr + '0';
    if not TextToFloat(PChar(lStr), Result, fvExtended) then
      Result := Def;
  except
    Result := Def;
  end;
end;


While you're at it, also change StrToCurrDef in the same unit to:

function StrToCurrDef(const Str: string; Def: Currency): Currency;
var
  lStr: string;
  i:integer;
begin
  lStr := '';
  for i := 1 to Length(Str) do
    if Str[i] in ['0'..'9','-','+', DecimalSeparator] then
      lStr := LStr + Str[i];
  try
    if not TextToFloat(PChar(lStr), Result, fvCurrency) then
      Result := Def;
  except
    Result := Def;
  end;
end;

edited on: 04-07-04 13:18

user72

2004-04-07 13:19

  ~0003699

Note: I modified the code to set lStr := '' at the beginning

anonymous

2004-04-07 13:45

viewer   ~0003701

Hello Peter,

it seems to work now. Maybe you could add this changes to the CVS?

Thanks for you fast support!

user72

2004-04-07 14:43

  ~0003702

Updated in CVS. You are welcome!

Issue History

Date Modified Username Field Change
2004-04-07 08:09 anonymous New Issue
2004-04-07 13:02 anonymous Note Added: 0003692
2004-04-07 13:07 user72 Note Added: 0003695
2004-04-07 13:07 user72 Status new => assigned
2004-04-07 13:07 user72 Assigned To => user72
2004-04-07 13:18 user72 Note Edited: 0003695
2004-04-07 13:19 user72 Note Added: 0003699
2004-04-07 13:45 anonymous Note Added: 0003701
2004-04-07 14:43 user72 Status assigned => resolved
2004-04-07 14:43 user72 Resolution open => fixed
2004-04-07 14:43 user72 Note Added: 0003702