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 hexstrtostream

Delphi 解决timage无法在窗体resize时改变canvas的大小

Delphi假死线程堵塞解决办法

Delphi 简单判断图片类型

Delphi 删除动态数组的指定元素

Delphi实现文件防删除

Delphi清除ie临时文件,历史记录

Delphi messagebox 使用

Delphi 2009 indy10 idhttp get 中文出现乱码的问题

Delphi 遍历硬盘所有文件目录

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



打赏

取消

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

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

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

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

评论

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