function TForm1.changeRmb(const strRmb:string):string;
var
txt,strhighlevel:string;
i,n,m,ilen,ipos:Integer; //n记录整数部分长度,m记录分数部分长度
strarray,strlevel:array of string;
p:pchar;
ispoint:boolean;//判断是否有小数点
begin
ispoint:=false;
result:='';
ipos:=0;
m:=0;
txt:=Trim(strRmb);
i:=1;
p:=PChar(txt);
//去除开头的0,以及.
if ((txt[1]='0') and (txt[2]<>'.')) or (txt[1]='.') then
begin
ShowMessage('第1位不能为0或者是.,退出操作');
exit;
end;
//检查字符的合法性
while (i<length(txt))do
begin
if (p^>'9') or ((p^<'0') and (P^<>'.')) then //ord('.')=46
begin
ShowMessage(PChar('第'+inttostr(i)+'位包含非数字字符,将退出操作'));
Exit;
end;
if P^='.' then
if ispoint then
begin
showmessage('太多小数点,将退出!');
exit;
end
else
begin
ipos:=i;
ispoint:=true;
end;
Inc(p);
Inc(i);
end;//while
ilen:=Length(txt);
if ispoint then
begin
n:=ipos-1;
m:=ilen-ipos;
end
else
n:=ilen;
//判断是否超过万,或亿
if m>3 then
begin
ShowMessage('小数点后位数超过3,无法转换!');
Exit;
end;
SetLength(strarray,ilen+8);
SetLength(strlevel,ilen+8); for i:=iLen downto 1 do
begin
if txt[i]<>'.' then
case strtoint(txt[i]) of
1:strarray[i]:='壹';
2:strarray[i]:='贰';
3:strarray[i]:='叁';
4:strarray[i]:='肆';
5:strarray[i]:='伍';
6:strarray[i]:='陆';
7:strarray[i]:='柒';
8:strarray[i]:='捌';
9:strarray[i]:='玖';
0:
begin
strarray[i]:='零';
if i<ilen then //如果低位也为零,低位零不显示
if (strarray[i+1]= '') or (strarray[i+1]= '零') then
begin
//strarray[i+1]:= '';
strarray[i]:= '';
end;
if i=n then strarray[i]:='';
strlevel[i]:='';
end;
end; //case
end;
//先处理 小数点部分 if m>0 then
begin
for i:=m downto 1 do
begin
strlevel[ipos+i]:='';
case i-1 of
0:
if txt[ipos+i]='0' then
strarray[ipos+i]:=''
else
strlevel[ipos+i]:='角';
1:
if txt[ipos+i]='0' then
strarray[ipos+i]:=''
else
strlevel[ipos+i]:='分';
2:
if txt[ipos+i]='0' then
strarray[ipos+i]:=''
else strlevel[ipos+i]:='厘';
end;
Result:=strarray[ipos+i]+strlevel[ipos+i]+result;
end;
end;
if ispoint and (txt[ipos-1]='0') and (n=1) then
Result:=result+'' //如果少于1块时,不要显示元。
else
Result:='元'+result; for i:=n downto 1 do
begin case n-i of
0,4,8,12: strlevel[i]:='';
1,5,9,13: strlevel[i]:='拾';
2,6,10,14: strlevel[i]:='佰';
3,7,11,15: strlevel[i]:='仟';
end; //case
if (txt[i]='0') then strlevel[i]:='';
//要处理零 以及加上万、亿
if n-i=4 then
begin
if strarray[i]='零' then strarray[i]:='';
Result:=strarray[i]+strlevel[i]+'万'+result
end
else if n-i=8 then
begin
if strarray[i]='零' then strarray[i]:='';
Result:=strarray[i]+strlevel[i]+'亿'+result
end //begin
else if n-i=12 then
begin
if strarray[i]='零' then strarray[i]:='';
Result:=strarray[i]+strlevel[i]+'兆'+result
end //begin
else
Result:=strarray[i]+strlevel[i]+result;
end; //for
end;

  

数字转换大写人民币的delphi实现的更多相关文章

  1. 算法--java实现将数字转换成人民币大写(迅雷面试题)

    今天去迅雷面试,是个数字转换成人民币的算法题: public class Rmb { /** * 人民币的基本信息和操作 * * @author soyoungboy * @version 1.0 * ...

  2. js 将数字转换成人民币大写的方法

    //将数字转换成人民币大写的方法 var digitUppercase = function (n) { var fraction = ['角', '分']; var digit = [ '零', ' ...

  3. java 金额数字转换大写算法

    根据人民币大写金额规范,转换有几点要注意的: 阿拉伯数字中间有"0"时,中文大写金额中间可以只写一个"零"字.如¥1,409.50,应写成人民币壹仟肆佰零玖圆伍 ...

  4. C#小写数字金额转换成大写人民币金额的算法

    C#小写数字金额转换成大写人民币金额的算法 第一种方法: using System.Text.RegularExpressions;//首先引入命名空间 private string DaXie(st ...

  5. ORACLE数字转换人民币大写

    ORACLE 数字转换人民币大写     示例.   数字                    :183066999230.68 人民币大写        :壹仟捌佰参拾亿陆仟陆佰玖拾玖万玖仟贰佰参 ...

  6. C# 数字转换成大写

    /// <summary> /// 数字转大写 /// </summary> /// <param name="Num">数字</para ...

  7. C# 数字转换成汉字大写 数值转换成汉字大写

    1.数字转换成汉字大写 public string NumToChinese(string x) { //数字转换为中文后的数组 //转载请注明来自 http://www.shang11.com st ...

  8. js 将数字转换成中文大写

    //完成将 toChineseNum, 可以将数字转换成中文大写的表示,处理到万级别,例如 toChineseNum(12345),返回 一万二千三百四十五. const toChinesNum = ...

  9. PHP 数字转大写

    <?php header("content-type:text/html;charset=utf-8"); function numToRmb($num){ $rmbNum ...

随机推荐

  1. python concurrent.futures.Threadpoolexcutor的有界队列和无界队列

    1.默认是无界队列,如果生产任务的速度大大超过消费的速度,则会把生产任务无限添加到无界队列中,这样一来控制不了生产速度,二来是会造成系统内存会被队列中的元素堆积增多而耗尽. 2.改写为有界队列 cla ...

  2. 【中间件安全】Apache 安全加固规范

    1. 适用情况 适用于使用Apahce进行部署的Web网站. 2. 技能要求 熟悉Apache配置文件,能够利用Apache进行建站,并能针对站点使用Apache进行安全加固. 3. 前置条件 1. ...

  3. 【转载】eclipse常用插件在线安装地址或下载地址

    一,反编译插件: A.Jadclipse 1.打开eclipse增加站点:http://jadclipse.sf.net/update,在线安装好JDT Decompiler 3.4.0 2.http ...

  4. 【连载6】二手电商APP的导购功能与关系链机制分析

    导读:得益于十余年来各种一手电商平台对市场与用户的教育以及共享.分享经济浪潮的兴起,互联网化的二手.闲置商品买卖.置换成为越来越普遍且简单可实现的生活方式. 第三章目录: 三.对比:主流二手电商竞品的 ...

  5. Pthon Matplotlib 画图

    一.普通绘图 import matplotlib.pyplot as plt import numpy as np # 绘制普通图像 x = np.linspace(-1, 1, 50) y1 = 2 ...

  6. Ubuntu下配置使用mysql

    很多生产环境都使用linux系统,相比于window系统,界面真的做的不够人性化,但是简洁高效也是linux的优点吧.在linux上使用mysql又是不一样的风景吧.

  7. 局域网里别人如何访问我本地电脑里的nginx网站

    1.修改nginx.conf配置文件(我这里配了二级域名,所以我在二级域名配置文件修改) 把deny all全部改成autoindex on 2.关闭防火墙 3.重启nginx

  8. 洛谷试炼场-简单数学问题-P1088 火星人

    洛谷试炼场-简单数学问题 A--P1088 火星人 Description 人类终于登上了火星的土地并且见到了神秘的火星人.人类和火星人都无法理解对方的语言,但是我们的科学家发明了一种用数字交流的方法 ...

  9. 【紫书】Urban Elevations UVA - 221 离散化

    题意:给你俯视图,要求依次输出正视图中可以看到的建筑物 题解:任意相邻的x间属性相同,所以离散化. 坑:unique只能对数组用.下标易错 list不能找某元素的next.用了个很麻烦的处理 数组: ...

  10. shell脚本之分析oracle数据库数据泵日志中表的大小

    1.分析日志格式如下 . . imported "xxx_330508"."xxx_T_DATA" 46.17 MB 268 rows . . imported ...