""和"#"开始,分号结束是HTML语言数字式编码.
自己写程序比较麻烦.
就用IE存放html网页的功能,存为GB2312,就可以实现所说变换了.
人民币写法小写转大写,数字转成汉字书写。
%
function Money(thenumber)
dim Money,i,String1,String2,length,checkp'定义变量
dim one(),onestr()'定义数组
String1 = "零壹贰叁肆伍陆柒捌玖"
String2 = "万仟佰拾亿仟佰拾万仟佰拾元角分厘毫"
checkp=instr(thenumber,".")'判断是否含有小数位
if checkp0 then
thenumber=replace(thenumber,".","")'去除小数位
end if
length=len(thenumber) '取得数据长度
redim one(length-1)'重新定义数组大小
redim onestr(length-1)'重新定义数组大小
for i=0 to length-1
one(i)=mid(thenumber,i+1,1) '循环取得每一位的数字
one(i)=mid(string1,one(i)+1,1)'循环取得数字对应的大写
if checkp=0 then
'不含有小数的数据其数字对应的单位
onestr(i)=mid(string2,14-length+i,1)
else
'含有小数的数据其数字对应的单位
onestr(i)=mid(string2,15-length+i+len(thenumber)-checkp,1)
end if
one(i)=one(i)onestr(i)'将数字与单位组合
next
Money=replace(join(one)," ","") '取得数组中所有的元素,并连接起来
Money=replace(Money,"零元","元")
Money=replace(Money,"零万","万")
Money=replace(Money,"零亿","亿")
Money=replace(Money,"零仟","零")
Money=replace(Money,"零佰","零")
Money=replace(Money,"零拾","零")
do while not instr(Money,"零零")=0
Money=replace(Money,"零零","零")
loop
response.write Money '显示结果
end function
%
以Excel为例,其中的具体步骤如下:
1、直接打开相关窗口,在方方格子那里点击数值进入。
2、下一步弹出新的菜单,需要找到图示按钮并选择跳转。
3、这个时候如果没问题,就继续确定设置中文转阿拉伯数字。
4、这样一来会发现对应结果,即可达到目的了。
font color=ff0000人均消费:/font%=getChinese(average)%br
%
Function getChinese(num)
select case num
case "1"
getChinese="十元"
case "2"
getChinese="十八元"
....
End Select
End Function
%
好像0x8754对应汉字好像不是1,你可以用这个试一试:
public class Test4
{
public static void main(String[] args)
{
System.out.println((char)(Integer.parseInt("8754", 16)));
System.out.println((char)0x8754);
}
}
没悬赏金,我也为你解答。
多项选择与子文本替换联合使用,可批量处理,精简代码。以下代码你试试,是否符合你的要求?
‘方法一:
'----------------------------------------------------------------------------------------
.版本 1
.子程序 _按钮1_被单击
.局部变量 数据, 文本型
.局部变量 计数, 整数型
.局部变量 字符, 文本型, , , 待转换的字符
.局部变量 数字, 文本型, , , 转换后的字符
数据 = 编辑框1.内容
.计次循环首 (10, 计数)
' 中文转为数字
字符 = 多项选择 (计数, “一”, “二”, “三”, “四”, “五”, “六”, “七”, “八”, “九”, “零”)
数字 = 多项选择 (计数, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “0”)
数据 = 子文本替换 (数据, 字符, 数字, , , 假)
' 英文转为数字
字符 = 多项选择 (计数, “one”, “two”, “three”, “four”, “five”, “six”, “seven”, “eight”, “nine”, “zero”)
数字 = 多项选择 (计数, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “0”)
数据 = 子文本替换 (数据, 字符, 数字, , , 假)
.计次循环尾 ()
编辑框1.内容 = 数据
'
'方法二:
'----------------------------------------------------------------------------------------
.版本 2
.子程序 _按钮2_被单击
.局部变量 数据, 文本型
.局部变量 计数, 整数型
.局部变量 字符, 文本型, , , 待转换的字符
.局部变量 数字, 文本型, , , 转换后的字符
数据 = 编辑框1.内容
.计次循环首 (20, 计数)
字符 = 多项选择 (计数, “一”, “二”, “三”, “四”, “五”, “六”, “七”, “八”, “九”, “零”, “one”, “two”, “three”, “four”, “five”, “six”, “seven”, “eight”, “nine”, “zero”)
数字 = 多项选择 (计数, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “0”)
数据 = 子文本替换 (数据, 字符, 数字, , , 假)
.计次循环尾 ()
编辑框1.内容 = 数据