haifeng585 2006-3-17 12:51
大小写转换
我的页面上有一个输入框
现在要求是输入小写的金额
而后转换成大写保存到数据库中
实在想不出 各位帮我想想
shanzhiyin 2006-3-17 12:52
思路:
m=""
n=trim(request("textname"))
for i=1 to len(n)
if mid(n,i,1)="1" then
m=m&"壹"
end if
if mid(n,i,1)="2" then
m=m&"贰"
end if
....
if mid(n,i,1)="." then
m=m&"点"
end if
next
huaerfeifei 2006-3-17 12:52
显示中文币值
Function DispMoneyCHS(Money)
'壹拾壹亿壹仟贰佰叁拾肆万伍仟陆佰柒拾捌元玖角零分00,000,000.00 <b><font face="幼圆">收款音</font></b>
Money=FormatNumber(trim(Money),2)
MoneyLen=len(Money)
TempStr=""
'十亿位
If MoneyLen<16 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,16),1) )&" <b><font face='幼圆'>拾</font></b> "
End if
'亿位
If MoneyLen<14 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,14),1) )&" <b><font face='幼圆'>亿</font></b> "
End if
'千万位
If MoneyLen<13 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,13),1) )&" <b><font face='幼圆'>仟</font></b> "
End if
'百万位
If MoneyLen<12 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,12),1) )&" <b><font face='幼圆'>佰</font></b> "
End if
'十万位
If MoneyLen<10 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,10),1) )&" <b><font face='幼圆'>拾</font></b> "
End if
'万位
If MoneyLen<9 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,9),1) )&" <b><font face='幼圆'>万</font></b> "
End if
'千位
If MoneyLen<8 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,8),1) )&" <b><font face='幼圆'>仟</font></b> "
End if
'百位
If MoneyLen<6 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,6),1) )&" <b><font face='幼圆'>佰</font></b> "
End if
'十位
If MoneyLen<5 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,5),1) )&" <b><font face='幼圆'>拾</font></b> "
End if
'个位
If MoneyLen<4 then
TempStr=TempStr &""
Else
TempStr=TempStr & GetNumCHS( left( right(Money,4),1) )&" <b><font face='幼圆'>元</font></b> "
End if
'角
If right(Money,2)="00" then
TempStr=TempStr &"整"
Else
TempStr=TempStr & GetNumCHS( left( right(Money,2),1) )&" <b><font face='幼圆'>角</font></b> "
End if
'分
If right(Money,2)<>"00" then
TempStr=TempStr & GetNumCHS( right(Money,1))&" <b><font face='幼圆'>分</font></b>"
End if
DispMoneyCHS=TempStr
End Function
Function GetNumCHS(Num)
Select Case Num
Case "1"
GetNumCHS="壹"
Case "2"
GetNumCHS="贰"
Case "3"
GetNumCHS="叁"
Case "4"
GetNumCHS="肆"
Case "5"
GetNumCHS="伍"
Case "6"
GetNumCHS="陆"
Case "7"
GetNumCHS="柒"
Case "8"
GetNumCHS="捌"
Case "9"
GetNumCHS="玖"
Case "0"
GetNumCHS="零"
End Select
End Function
Nothing 2006-3-17 15:17
请看我以前写的代码
根据数字的读法,写了一个把数字转成中文字符串的程序
参数一为数字
参数二为是不是反回人民币大写
参数三为是不是直接读数字,否则带有十百等单位
参数四为设置小数点后面的位数,默认为4
使用方法是
t=GetChinaNum(20005.000436, , , 7)'返回 “二千零五点零零零四三六”
t=GetChinaNum(2005.436, True, , 7)'返回“贰仟零伍元肆角肆分”
t=GetChinaNum(2005.436, , True, 7)'返回“二零零五点四三六”
下面是程序代码
[code]
Function GetChinaNum(otherNum As Double, Optional isRMB As Boolean, Optional numOption As Boolean, Optional dotNum As Integer) As String
On Error Resume Next
num = Trim(Str(Int(otherNum)))
If isRMB Then
numwei = "拾佰仟万拾佰仟亿拾佰仟"
numshu = "零壹贰叁肆伍陆柒捌玖拾"
Else
numwei = "十百千万十百千亿十百千"
numshu = "零一二三四五六七八九十"
End If
If otherNum < 20 And otherNum >= 10 Then
num = Right(num, 1)
GetChinaNum = Left(numwei, 1)
End If
For i = 1 To Len(num)
bstr = Mid(num, i, 1)
If numOption Then
GetChinaNum = GetChinaNum + Mid(numshu, Val(bstr) + 1, 1)
Else
GetChinaNum = GetChinaNum + Mid(numshu, Val(bstr) + 1, 1)
If bstr = "0" Then
If Mid(numwei, Len(num) - i, 1) = "万" Or Mid(numwei, Len(num) - i, 1) = "亿" Then
Do While Right(GetChinaNum, 1) = "零"
GetChinaNum = Left(GetChinaNum, Len(GetChinaNum) - 1)
Loop
GetChinaNum = GetChinaNum + Mid(numwei, Len(num) - i, 1)
End If
Else
GetChinaNum = GetChinaNum + Mid(numwei, Len(num) - i, 1)
End If
GetChinaNum = Replace(GetChinaNum, "零零", "零")
End If
Next i
If numOption = False Then
Do While Right(GetChinaNum, 1) = "零"
GetChinaNum = Left(GetChinaNum, Len(GetChinaNum) - 1)
Loop
End If
If isRMB Then
numrmb = "元角分"
GetChinaNum = GetChinaNum + Mid(numrmb, 1, 1)
If Val(num) <> otherNum Then
num = Trim(Str(Round(otherNum - Val(num), 2)))
For i = 2 To Len(num)
bstr = Mid(num, i, 1)
GetChinaNum = GetChinaNum + Mid(numshu, Val(bstr) + 1, 1) + Mid(numrmb, i, 1)
Next i
Else
GetChinaNum = GetChinaNum + "整"
End If
Else
If Val(num) <> otherNum Then
If dotNum = 0 Then dotNum = 4
num = Trim(CStr(Round(otherNum - Val(num), dotNum)))
If GetChinaNum = "" Then GetChinaNum = "零"
GetChinaNum = GetChinaNum + "点"
For i = 2 To Len(num)
bstr = Mid(num, i, 1)
GetChinaNum = GetChinaNum + Mid(numshu, Val(bstr) + 1, 1)
Next i
End If
End If
End Function
[/code]