本文整理自网络,侵删。
自己建立一个Button1按钮
procedure TForm1.Button1Click(Sender: TObject);
var
S, T: string;
begin
Str(1.4:2:1, T); //用Str转换了T的格式
S := T + ' Truncs to ' + IntToStr(Trunc(1.4)) + #13#10; //回车加换行
Str(1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(1.5)) + #13#10; //S不断叠加
Str(-1.4:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.4)) + #13#10; //TrunC转换函数
Str(-1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.5)); //TrunC把小数点后面的全去掉了.
MessageDlg(S, mtInformation, [mbOk], 0);
end; 相关阅读 >>
Delphi firedac 下的 sqlite [12] - 备忘录
Delphi读取radiogroup选中按钮的string文本
Delphi 判断指定字符串是否开头 startstext用法
Delphi 读文件到十六进制的函数(Delphi 7 下可用)
更多相关阅读请进入《Delphi》频道 >>