怎么用format函数,把一个数字转换为制定位数的字符串,数字位数肯定小于指定的字符串位数.
例如:
数字 98
转换成指定6位的字符串
为   '000098'wait...中

解决方案 »

  1.   

    Format('x=%d', [12]); //'x=12' //最普通
    Format('x=%3d', [12]); //'x= 12' //指定宽度
    Format('x=%f', [12.0]); //'x=12.00' //浮点数
    Format('x=%.3f', [12.0]); //'x=12.000' //指定小数
    Format('x=%.*f', [5, 12.0]); //'x=12.00000' //动态配置
    Format('x=%.5d', [12]); //'x=00012' //前面补充0
    Format('x=%.5x', [12]); //'x=0000C' //十六进制
    Format('x=%1:d%0:d', [12, 13]); //'x=1312' //使用索引
    Format('x=%p', [nil]); //'x=00000000' //指针
    Format('x=%1.1e', [12.0]); //'x=1.2E+001' //科学记数法
    Format('x=%%', []); //'x=%' //得到"%"
    S := Format('%s%d', [S, I]); //S := S + StrToInt(I); //连接字符串
      

  2.   

    edit1.Text := formatfloat('000000',98);
      

  3.   

    Format('%.6d', [12]);
    好了谢谢.