Delphi 7 -如何比较我的标签标题中的值(货币与十进制),值即标签1 = '12345.55'和标签2 = '12345.56',并想知道哪一个是更大的值
使用SysUtils.StrToCurr()
函数将标签标题转换为Currency
值,然后可以使用普通算术运算符比较这些值。
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;