delphi 数字转换成中文


本文整理自网络,侵删。

 
获取当前日期,日期为数字。将数字转换成中文。

function TForm1.GetCNDay():string;       //result是function默认的返回值变量
var
    str,strYear,strMonth,strDay,e,n,s : string;
    year,month,day,v_index,v_len,i : Integer;
begin
    e:='0123456789';
    n:='?一二三四五六七八九';
    v_index:=1;
    Result:='';
 
    strYear:=formatDateTime('yyyy',Now());
    strMonth:= formatDateTime('mm',Now());
    strDay:= formatDateTime('dd',Now());
    year:=StrToInt(strYear);
    month:=StrToInt(strMonth);
    day:=StrToInt(strDay);
 
    if month<10 then
       strMonth:=IntToStr(month)
    else
    if month =10 then
        strMonth:='十'
    else
    if month>10 then
        strMonth:='十' + IntToStr(month-10);
 
    strMonth:=strMonth+'月';
 
    if day <10 then
        strDay:=inttostr(day)
    else
    if(day = 10) then
        strDay:='十'
    else
    if(day>10) and (day<20)then
        strDay:='十'+ inttostr(day-10)
    else
    if(day = 20)then
        strDay:='二十'
    else
    if(day>20) and (day < 30)then
        strDay:='二十'+ inttostr(day-20)
    else
    if(day =30)then
        strDay:='三十'
    else
    if(day=31)then
        strDay:='三十一';
 
    str:= strYear +'年'+ strMonth + strDay+'日';
    v_len:=Length(str);
    for i:=1 to v_len do
    begin
       s:=MidStr(str,i,1);
       if Pos(s,e)>0 then
          Result:=Result+MidStr(n,Pos(s,e),1)
       else
          Result:=Result+s;
    end;
 
end;

相关阅读 >>

Delphi 把文件锁定到任务栏

Delphi 获取系统内存状态

Delphi url protocol 让浏览器运行本地的exe程序

如何在Delphi中禁用关于“返回值...可能未定义”的警告?

Delphi结合winrar生成自解压文件

Delphi extctrls.frame3d

Delphi unigui hyperserver

Delphi android 拨打电话

Delphi 读取软件卸载信息和桌面图标列表

Delphi 最简单的判断数字函数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...