1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| function CellCompare(const AStringGrid: TStringGrid;const Column, Index1, Index2: Integer): Integer;
var
ExtValue: Extended;
CurrValue: Currency;
DateValue: TDateTime;
IntValue: Integer;
S1,S2:String;
begin
S1:=AStringGrid.Cells[Column, Index1];
S2:=AStringGrid.Cells[Column, Index2];
if (TryStrToInt(S1,IntValue))
and (TryStrToInt(S2,IntValue))
then Result:=CompareValue(StrToInt(S1), StrToInt(S2))
else if (TryStrToCurr(S1,CurrValue))
and (TryStrToCurr(S2,CurrValue))
then result:=CompareValue(StrToCurr(S1), StrToCurr(S2), 0)
else if (TryStrToFloat(S1,ExtValue))
and (TryStrToFloat(S2,ExtValue))
then Result:=CompareValue(StrToFloat(S1), StrToFloat(S2), 0)
else if (TryStrToDate(S1,DateValue))
and (TryStrToDate(S2,DateValue))
then Result:=CompareDate(StrToDate(S1), StrToDate(S2))
else Result:=AnsiCompareText(S1, S2);
end; |
Partager