1、将金额转换成大写金额;
2、根据大写金额依次朗读出来;
为此,需要完成以下内容:
1、分别录制各wav文件:0,1,2,3,4,5,6,7,8,9,元,角,分,拾,佰,仟,万,亿,整
2、在工程中声明两个external 函数(windows的api函数),用于发声;
function boolean sndplaysounda (string soundname, uint flags) library "winmm.dll"
function uint waveoutgetnumdevs () library "winmm.dll"
3、新建一函数用于在程序中调用发声:
function playsound(string as_filename,integer ai_option) returns integer
该函数的代码如下:
uint lui_numdevs
lui_numdevs = waveoutgetnumdevs()
if lui_numdevs > 0 then
sndplaysounda(as_filename,ai_option)
return 1
else
return -1
end if
4、新建一函数用于将小写金额转换成大写金额:
function xx2dx(decimal ls) returns string
代码实现如下:
string dx_sz,dx_dw,str_int,str_dec,dx_str,fu,a,b,b2,c,d,result
long num_int,num_dec,len_int,i,a_int,pp
dx_sz = "零壹贰叁肆伍陆柒捌玖"
dx_dw = "万仟佰拾亿仟佰拾万仟佰拾元"
/*处理小于零情况*/
if ls<0 then
ls = ls*(-1)
fu = "负"
else
fu = ""
end if
/*取得整数及整数串*/
dx_str = string(ls)
if (ls>0) and (ls<1) then dx_str = "0"+dx_str
pp = pos(dx_str,".")
if pp>0 then
str_int = mid(dx_str,1,pos(dx_str,".")-1)
else
str_int = dx_str
end if
num_int = long(str_int)
/*取得小数及小数串*/
if (ls>0) and (ls<1) then
num_dec = ls * 100
else
num_dec = (ls - num_int) * 100
end if
str_dec = string(num_dec)
len_int = len(str_int)
dx_str = ""
/*转换整整部分*/
for i = 1 to len_int
/*a为小写数字字符,b为对应的大写字符,c为对应大写单位,d为当前大写字符串的最后一个汉字*/
a= mid(str_int,i,1)
a_int = long(a)
b = mid(dx_sz,(a_int*2)+1,2)
c = mid(dx_dw,((13 - len_int +i - 1)*2+1),2)
if dx_str<>"" then
d=mid(dx_str,len(dx_str)-1,2)
else
d= ""
end if
if (b="零") and ((d="零") or (b=b2) or (c="元") or (c="万") or (c="亿")) then b = ""
if (a="0") and (c<>"元") and (c<>"万") and (c<>"亿") then c=""
if ((c="元") or (c="万") or (c="亿")) and (d="零") and (a="0") then
dx_str = mid(dx_str,1,len(dx_str)-2)
d=mid(dx_str,len(dx_str)-1,2)
if ((c="元") and (d="万")) or ((c="万") and (d="亿")) then c = ""
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器