刚写的一个处理函数
<%
Dim DataType,NewType,NewDataType,CenterType,EndType,LingType
DataType=Array("元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟")
LingType=Array("角","分")
Function GetChar(Char)
Dim Str
If Instr(Char,".")<>0 Then
'如果包含零钱
Str=Split(Char,".")
If Len(Str(0))<=12 Then
For I=1 To Len(Str(0))
'根据数字的长度创建单位
If NewType="" Then
NewType=DataType(I-1)
Else
NewType=NewType&","&DataType(I-1)
End If
Next
NewDataType=Split(NewType,",")
For I=Len(Str(0)) To 1 Step -1
If CenterType="" Then
CenterType=NewDataType(I-1)
Else
CenterType=CenterType&","&NewDataType(I-1)
End If
Next
EndType=Split(CenterType,",")
For I=1 To Len(Str(0))
If MID(Str(0),I,1)<>0 Then
Response.Write NumToChar(MID(Str(0),I,1))&EndType(I-1)
End If
Next
If Right(Str(0),1)=0 Then
Response.Write "元"
End If
For I=1 To 2
If MID(Str(1),I,1)<>0 Then
Response.Write NumToChar(MID(Str(1),I,1))&LingType(I-1)
End If
Next
Else
Response.Write"長度超出限制!"
End If
Else
'不包含零钱
If Len(Char)<=12 Then
For I=1 To Len(Char)
'根据数字的长度创建单位
If NewType="" Then
NewType=DataType(I-1)
Else
NewType=NewType&","&DataType(I-1)
End If
Next
NewDataType=Split(NewType,",")
For I=Len(Char) To 1 Step -1
If CenterType="" Then
CenterType=NewDataType(I-1)
Else
CenterType=CenterType&","&NewDataType(I-1)
End If
Next
EndType=Split(CenterType,",")
For I=1 To Len(Char)
If MID(Char,I,1)<>0 Then
Response.Write NumToChar(MID(Char,I,1))&EndType(I-1)
End If
Next
If Right(Char,1)=0 Then
Response.Write "元"
End If
Else
Response.Write"長度超出限制!"
End If
End If
End Function
'转换函数
Function NumToChar(Str)
Select Case Str
Case "0"
NumToChar="零"
Case "1"
NumToChar="壹"
Case "2"
NumToChar="贰"
Case "3"
NumToChar="叁"
Case "4"
NumToChar="肆"
Case "5"
NumToChar="伍"
Case "6"
NumToChar="陆"
Case "7"
NumToChar="柒"
Case "8"
NumToChar="捌"
Case "9"
NumToChar="玖"
End Select
End Function
Call GetChar("4000.95")
%>
[此贴子已经被作者于2006-7-28 9:46:18编辑过]