转 .Net/C#/VB/T-SQL/Java/Script 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
2005-07-11 10:08
1236 查看
下面的是转贴
C# Code:
namespace Microshaoft
namespace Microshaoft
namespace Test
T-SQL UDF Code:
alter function ConvertNumberToChinese(@ varchar(100))
returns varchar(100)
as
begin
--declare @ varchar(100)
--set @ = '101140101031013'
declare @s varchar(100)
set @s = ''
declare @p integer
set @p = 0
declare @m integer
set @m = len(@) % 4
declare @k integer
set @k = len(@)/4
select @k = @k + 1
where @m > 0
declare @i integer
set @i = @k
while (@i > 0)
begin --outer
declare @L integer
set @L = 4
select @L = @m
where @i = @k and @m != 0
declare @ss varchar(4)
set @ss = substring(@,@p+1,@L)
declare @ll integer
set @ll = len(@ss)
--inner
declare @j integer
set @j = 0
while (@j < @ll) --inner
begin --inner
declare @n integer
set @n = cast(substring(@ss,@j+1,1) as integer)
declare @num varchar(2)
select @num = Num
from (
select 0 as id,'零' as Num
union all select 1,'壹'
union all select 2,'贰'
union all select 3,'叁'
union all select 4,'肆'
union all select 5,'伍'
union all select 6,'陆'
union all select 7,'柒'
union all select 8,'捌'
union all select 9,'玖'
) Nums
where id = @n
if @n = 0
begin
select @s = @s + @num
where @j < @ll - 1
and cast(substring(@ss,(@j+1)+1,1) as integer) > 0
and right(@ss,1) != @num
end
else
begin
declare @jj integer
set @jj = 1
select @jj = @j - 1
where @j > 1
select @s = @s + @num
where not (@n = 1
and @j = @ll - 2
and (len(@s) = 0
or right(@s,1) = '零'
)
)
select @s = @s + digit
from (
select 0 as id,'' as digit
union all select 1,'拾'
union all select 2,'佰'
union all select 3,'仟'
) digits
where id = @ll - @j - 1
end
set @j = @j + 1 --inner
end --inner
set @p = @p + @L
declare @unit varchar(10)
select @unit = Unit
from (
select 0 as id,'' as Unit
union all select 1,'[万]'
union all select 2,'[亿]'
union all select 3,'[万亿]'
) Units
where id = @i - 1
if @i < @k
begin
select @s = @s + @unit
where cast(@ss as integer) != 0
end
else
begin
set @s = @s + @unit
end
set @i = @i - 1 -- outer
end --out
return @s
end
VB6 Code:
《VB6 之数据格式化对象使用技巧》
http://search.csdn.net/Expert/topic/38/38970.xml?temp=.5078089
<<精华: 将金额小写转大写的代码可转到亿位>>
http://www.dev-club.com/club/bbs/showEssence.asp?id=20684&page=1
VB.Net Code:
可自行将 C# Code 编译成 EXE 后, Reflector 反编译获取 VB.Net/Delphi.Net/IL 等语言源码
Java Code:
public class Class1
JavaScript:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="playyuer㊣www.Microshaoft.com">
</HEAD>
<BODY>
</SCRIPT>
</BODY>
</HTML>
原文:http://www.cnblogs.com/microshaoft/archive/2005/04/02/131008.html
|
namespace Microshaoft
namespace Microshaoft
namespace Test
T-SQL UDF Code:
alter function ConvertNumberToChinese(@ varchar(100))
returns varchar(100)
as
begin
--declare @ varchar(100)
--set @ = '101140101031013'
declare @s varchar(100)
set @s = ''
declare @p integer
set @p = 0
declare @m integer
set @m = len(@) % 4
declare @k integer
set @k = len(@)/4
select @k = @k + 1
where @m > 0
declare @i integer
set @i = @k
while (@i > 0)
begin --outer
declare @L integer
set @L = 4
select @L = @m
where @i = @k and @m != 0
declare @ss varchar(4)
set @ss = substring(@,@p+1,@L)
declare @ll integer
set @ll = len(@ss)
--inner
declare @j integer
set @j = 0
while (@j < @ll) --inner
begin --inner
declare @n integer
set @n = cast(substring(@ss,@j+1,1) as integer)
declare @num varchar(2)
select @num = Num
from (
select 0 as id,'零' as Num
union all select 1,'壹'
union all select 2,'贰'
union all select 3,'叁'
union all select 4,'肆'
union all select 5,'伍'
union all select 6,'陆'
union all select 7,'柒'
union all select 8,'捌'
union all select 9,'玖'
) Nums
where id = @n
if @n = 0
begin
select @s = @s + @num
where @j < @ll - 1
and cast(substring(@ss,(@j+1)+1,1) as integer) > 0
and right(@ss,1) != @num
end
else
begin
declare @jj integer
set @jj = 1
select @jj = @j - 1
where @j > 1
select @s = @s + @num
where not (@n = 1
and @j = @ll - 2
and (len(@s) = 0
or right(@s,1) = '零'
)
)
select @s = @s + digit
from (
select 0 as id,'' as digit
union all select 1,'拾'
union all select 2,'佰'
union all select 3,'仟'
) digits
where id = @ll - @j - 1
end
set @j = @j + 1 --inner
end --inner
set @p = @p + @L
declare @unit varchar(10)
select @unit = Unit
from (
select 0 as id,'' as Unit
union all select 1,'[万]'
union all select 2,'[亿]'
union all select 3,'[万亿]'
) Units
where id = @i - 1
if @i < @k
begin
select @s = @s + @unit
where cast(@ss as integer) != 0
end
else
begin
set @s = @s + @unit
end
set @i = @i - 1 -- outer
end --out
return @s
end
VB6 Code:
《VB6 之数据格式化对象使用技巧》
http://search.csdn.net/Expert/topic/38/38970.xml?temp=.5078089
<<精华: 将金额小写转大写的代码可转到亿位>>
http://www.dev-club.com/club/bbs/showEssence.asp?id=20684&page=1
VB.Net Code:
可自行将 C# Code 编译成 EXE 后, Reflector 反编译获取 VB.Net/Delphi.Net/IL 等语言源码
Java Code:
public class Class1
JavaScript:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="playyuer㊣www.Microshaoft.com">
</HEAD>
<BODY>
</SCRIPT>
</BODY>
</HTML>
原文:http://www.cnblogs.com/microshaoft/archive/2005/04/02/131008.html
相关文章推荐
- .Net/C#/VB/T-SQL/Java/Script 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
- .Net/C#/VB/T-SQL/Java 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
- .Net/C#/VB/T-SQL/Java 实现: 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
- 将天文数字转换成中文大写 (2000 年前的思路,打劫的,一点儿技术含量都没有)
- 将天文数字转换成中文大写(.Net/C#/VB/T-SQL/Java 实现)
- C#实现阿拉伯数字(小写金额)到大写中文(大写金额)的转换
- 使用C#实现阿拉伯数字到大写中文的转换
- C#实现阿拉伯数字(小写金额)到大写中文(大写金额)的转换
- java实现数字金额转换中文大写金额
- C# 实现将阿拉伯数字转换成中文大写金额
- Java中实现数字金额到中文大写字符的转换!!
- 关于C#实现阿拉伯数字转换成中文大写
- java实现金额数字转换为中文大写
- sql server 关于表中只增标识问题 C# 实现自动化打开和关闭可执行文件(或 关闭停止与系统交互的可执行文件) ajaxfileupload插件上传图片功能,用MVC和aspx做后台各写了一个案例 将小写阿拉伯数字转换成大写的汉字, C# WinForm 中英文实现, 国际化实现的简单方法 ASP.NET Core 2 学习笔记(六)ASP.NET Core 2 学习笔记(三)
- 使用C#实现阿拉伯数字到大写中文的转换-第二种方法
- 数字金额转换中文大写Java实现
- java 实现将String字符串大写中文数字转换成int类型整数
- C#实现阿拉伯数字到大写中文的转换
- 使用C#实现阿拉伯数字到大写中文的转换-第二种方法
- Java中实现数字金额到中文大写字符的转换!! 选择自 netfalcon 的 Blog