Delphi 7 - 如何比较标签标题中的值(带小数的货币),值,即标签1 =' 12345.55'并标记2 =' 12345.56',并想知道哪一个值更大。
答案 0 :(得分:2)
使用Currency
函数将标签标题转换为SysUtils.StrToCurr()
值,然后您可以使用常规算术运算符比较这些值。
Uses
SysUtils;
var
Val1, Val2: Currency;
begin
Val1 := StrToCurr(Label1.Caption);
Val2 := StrToCurr(Label2.Caption);
if Val1 > Val2 then begin
// label1 is bigger
end
else if Val1 < Val2 then begin
// label2 is bigger
end
else begin
// they are the same
end;
end;