var s:string; a,b:double; i:integer;begin DBGridEh1.Columns[5].Footer.ValueType :=fvtStaticText; S:=DBGridEh1.GetFooterValue(0,DBGridEh1.Columns[6]); for i:=length(S) downto 1 do // 删除金额格式中的‘,’ if S[i]=',' then Delete(S, i, 1); A:=StrToFloat(S); S:=DBGridEh1.GetFooterValue(0,DBGridEh1.Columns[7]); for i:=length(S) downto 1 do if S[i]=',' then Delete(S, i, 1); B:=StrToFloat(S); if A<>0 then DBGridEh1.Columns[5].Footer.Value:= Format('%.2f',[B/A]);end;
本文介绍了一段使用 Delphi 进行数据处理的代码片段,主要涉及从表格中获取带格式的数据,并进行字符串清洗及数值计算的过程。具体包括移除货币数值中的逗号、将字符串转换为浮点数,以及进行条件判断后的比率计算。
429

被折叠的 条评论
为什么被折叠?



