<
%
function ccdate(str) ' 自定义日期类型转换函数
if isnull (str) or str = "" then
ccdate = ""
elseif isdate (str) then
if FormatDateTime (str,vbShortDate) = FormatDateTime ( " 1900-1-1 " ,vbShortDate) then
ccdate = ""
else
ccdate = FormatDateTime (str,vbShortDate)
end if
end if
end function
' set_date_null将不合法的日期和空值转换成null值,便于提交数据库时验证
' 编写时间:2005-11-24
' 编写人:kevin jan
function set_date_null(str)
if isnull (str) or str = "" then
set_date_null = null
elseif isdate (str) then
if FormatDateTime (str,vbShortDate) = " 1900-1-1 " then
set_date_null = null
else
set_date_null = FormatDateTime (str,vbShortDate)
end if
end if
end function
' set_int_null将不合法的整型数据转换成null值,便于提交数据库时验证
' 编写时间:2005-12-08
' 编写人:kevin jan
function set_int_null(str)
if isnull (str) or str = "" then
set_int_null = null
else
if IsNumeric (str) then
set_int_null = cint (str)
else
set_int_null = null
end if
end if
end function
' 处理数字客户端显示函数(要显示千位号)
function formatNumEx(tempValue,T_Type)
dim myValue,myStr,i,mylenth,loopNum,modNum,mySubStr
myValue = tempValue
if t_type = " money " then myValue = ccsn(tempValue)
if t_type = " int " then myValue = ccint(tempValue)
if t_type = " float " then myValue = ccsn(tempValue)
if T_Type = "" then
T_Type = " float "
myValue = ccsn(tempValue)
end if
if isnull (myValue) or myValue = "" or not IsNumeric (myValue) then myValue = 0
select case T_Type
case " int " ' 整数
myStr = FormatNumber (ccint(myValue), 0 , - 1 , 0 , - 2 )
case " money " ' 货币
' myStr=FormatNumber(myValue,2,-1,0,-2)
' myStr=FormatCurrency(ccsn(myValue),-1,-1,0,-2)
myStr = replace ( FormatCurrency (ccsn(myValue), - 1 , - 1 , 0 , - 2 ), " ¥ " , "" ) ' 去掉币符
case " float "
' myStr=FormatNumber(myValue,-1,-1,0,-2)
arrNum = split (ccsn(myValue), " . " )
mylenth = len (arrNum( 0 ))
if mylenth > 3 then
loopNum = mylenth \ 3
modNum = mylenth mod 3 ' 余数
if modNum <> 0 then myStr = mid (myValue, 1 ,modNum)
for i = 1 to loopNum
mySubStr = mid (myValue,modNum + 1 + (i - 1 ) * 3 , 3 )
if myStr = "" then
myStr = mySubStr
else
myStr = myStr & " , " & mySubStr
end if
next
else
myStr = arrNum( 0 )
end if
if cint ( ubound (arrNum)) <> 0 then
myStr = myStr & " . " & arrNum( 1 )
end if
case else
end select
formatNumEx = myStr
end function
function ccint(strr) ' 自定义整型数据转换函数
dim str
str = cCstr(strr)
if isnull (str) or str = "" then
ccint = 0
else
if IsNumeric (str) then
ccint = clng (str)
else
ccint = 0
end if
end if
end function
function cCSn(strr) ' 自定义浮点型数据转换函数
dim str
str = cCstr(strr)
if isnull (str) or str = "" then
cCSn = 0
else
if IsNumeric (str) then
' cCSn=formatNumEx(str,"float")
cCSn = Round (str, 6 )
else
cCSn = 0
end if
end if
end function
function cCstr(str) ' 自定义字符型数据转换函数
Dim RegExpObj
Dim resultStr,checkStr
if isnull (str) then
cCstr = ""
else
' 剔除多余空格
checkStr = str
do while Instr (checkStr, " " )
checkStr = Replace (checkStr, " " , " " ) ' 将两个连续的空格替换为一个空格
loop
checkStr = Trim (checkStr)
' 过滤非法字符,不允许字符有:<>'&/\%;
' Set RegExpObj=new RegExp
' RegExpObj.Global = True
' RegExpObj.Pattern = "[<>\'\;\%\&\/\\]"
' resultStr = RegExpObj.replace(checkStr, "")
' Set RegExpObj=Nothing
'
' resultStr =replace(resultStr,Chr("34"),"") '过滤"号
cCstr = checkStr
end if
end Function
function Replacestr(str) ' 增加一个字符串过滤函数,可以过滤特殊非法字符
Dim RegExpObj
Dim resultStr,checkStr
checkStr = str
if isnull (str) then
Replacestr = ""
else
' 剔除多余空格
do while Instr (checkStr, " " )
checkStr = Replace (checkStr, " " , " " ) ' 将两个连续的空格替换为一个空格
loop
resultStr = replace (checkStr, Chr ( " 34 " ), "" ) ' 过滤"号
resultStr = replace (resultStr, Chr ( " 60 " ), " 《 " ) ' 过滤<号
resultStr = replace (resultStr, Chr ( " 62 " ), " 》 " ) ' 过滤>号
resultStr = replace (resultStr, Chr ( " 38 " ), " and " ) ' 过滤&号
resultStr = replace (resultStr, Chr ( " 39 " ), " ‘ " ) ' 过滤'号
' resultStr =replace(resultStr,Chr("37"),"(百分比)") '过滤%号
Replacestr = resultStr
end if
end function
function cccur(strr) ' 自定义货币类型数据转换函数
dim str
str = cCstr(strr)
if isnull (str) or str = "" then
cccur = 0
else
str = replace (str, " ¥ " , "" )
str = replace (str, " $ " , "" )
if IsNumeric (str) then
' cccur=formatNumEx(str,"money")
cccur = Round (str, 2 )
else
cccur = 0
end if
end if
end function
function ccbool(str) ' 自定义bit bool 型数据转换函数
if isnull (str) or str = "" then
ccbool = false
Else
If " False " = str Or " True " = str Then
ccbool = cbool (str)
Else
if ccint(str) = 0 then
ccbool = false
elseif ccint(str) = 1 then
ccbool = True
Else
ccbool = cbool (str)
End if
End If
end if
end function
function fFormatNumber(str,t1,t2) ' 自定义格式化数字函数 t1 小数点后位数 t2 是否显示小数前的0
if isnull (str) or str = "" then str = 0
if IsNumeric (str) then
fFormatNumber = FormatNumber (str,ccint(t1),ccint(t2))
else
fFormatNumber = FormatNumber ( 0 ,ccint(t1),ccint(t2))
end if
end function
function fill_blank(str) ' 函数作用,对参数进行判断,如果为空或 null则返回 空格,这样来维护表格线的完整
if isnull (str) or str = "" then
fill_blank = " "
else
fill_blank = str
end if
end function
function fill_blank2(str) ' 函数作用,同上,此函数一般在会出现js中使用,因为 的 ;号,没有转义则不能正常显示
if isnull (str) or str = "" then
fill_blank2 = " "
else
fill_blank2 = str
end if
end function
Function long_check(info,s_num) ' 取定长字数函数, info需要进行截取的字符串,s_num截取得长度
if isnull (info) then info = ""
if len ( trim (info)) > ccint(s_num) then
long_check = left ( trim (info),ccint(s_num) - 2 ) & " .. "
else
long_check = trim (info)
end if
end Function
% >
function ccdate(str) ' 自定义日期类型转换函数
if isnull (str) or str = "" then
ccdate = ""
elseif isdate (str) then
if FormatDateTime (str,vbShortDate) = FormatDateTime ( " 1900-1-1 " ,vbShortDate) then
ccdate = ""
else
ccdate = FormatDateTime (str,vbShortDate)
end if
end if
end function
' set_date_null将不合法的日期和空值转换成null值,便于提交数据库时验证
' 编写时间:2005-11-24
' 编写人:kevin jan
function set_date_null(str)
if isnull (str) or str = "" then
set_date_null = null
elseif isdate (str) then
if FormatDateTime (str,vbShortDate) = " 1900-1-1 " then
set_date_null = null
else
set_date_null = FormatDateTime (str,vbShortDate)
end if
end if
end function
' set_int_null将不合法的整型数据转换成null值,便于提交数据库时验证
' 编写时间:2005-12-08
' 编写人:kevin jan
function set_int_null(str)
if isnull (str) or str = "" then
set_int_null = null
else
if IsNumeric (str) then
set_int_null = cint (str)
else
set_int_null = null
end if
end if
end function
' 处理数字客户端显示函数(要显示千位号)
function formatNumEx(tempValue,T_Type)
dim myValue,myStr,i,mylenth,loopNum,modNum,mySubStr
myValue = tempValue
if t_type = " money " then myValue = ccsn(tempValue)
if t_type = " int " then myValue = ccint(tempValue)
if t_type = " float " then myValue = ccsn(tempValue)
if T_Type = "" then
T_Type = " float "
myValue = ccsn(tempValue)
end if
if isnull (myValue) or myValue = "" or not IsNumeric (myValue) then myValue = 0
select case T_Type
case " int " ' 整数
myStr = FormatNumber (ccint(myValue), 0 , - 1 , 0 , - 2 )
case " money " ' 货币
' myStr=FormatNumber(myValue,2,-1,0,-2)
' myStr=FormatCurrency(ccsn(myValue),-1,-1,0,-2)
myStr = replace ( FormatCurrency (ccsn(myValue), - 1 , - 1 , 0 , - 2 ), " ¥ " , "" ) ' 去掉币符
case " float "
' myStr=FormatNumber(myValue,-1,-1,0,-2)
arrNum = split (ccsn(myValue), " . " )
mylenth = len (arrNum( 0 ))
if mylenth > 3 then
loopNum = mylenth \ 3
modNum = mylenth mod 3 ' 余数
if modNum <> 0 then myStr = mid (myValue, 1 ,modNum)
for i = 1 to loopNum
mySubStr = mid (myValue,modNum + 1 + (i - 1 ) * 3 , 3 )
if myStr = "" then
myStr = mySubStr
else
myStr = myStr & " , " & mySubStr
end if
next
else
myStr = arrNum( 0 )
end if
if cint ( ubound (arrNum)) <> 0 then
myStr = myStr & " . " & arrNum( 1 )
end if
case else
end select
formatNumEx = myStr
end function
function ccint(strr) ' 自定义整型数据转换函数
dim str
str = cCstr(strr)
if isnull (str) or str = "" then
ccint = 0
else
if IsNumeric (str) then
ccint = clng (str)
else
ccint = 0
end if
end if
end function
function cCSn(strr) ' 自定义浮点型数据转换函数
dim str
str = cCstr(strr)
if isnull (str) or str = "" then
cCSn = 0
else
if IsNumeric (str) then
' cCSn=formatNumEx(str,"float")
cCSn = Round (str, 6 )
else
cCSn = 0
end if
end if
end function
function cCstr(str) ' 自定义字符型数据转换函数
Dim RegExpObj
Dim resultStr,checkStr
if isnull (str) then
cCstr = ""
else
' 剔除多余空格
checkStr = str
do while Instr (checkStr, " " )
checkStr = Replace (checkStr, " " , " " ) ' 将两个连续的空格替换为一个空格
loop
checkStr = Trim (checkStr)
' 过滤非法字符,不允许字符有:<>'&/\%;
' Set RegExpObj=new RegExp
' RegExpObj.Global = True
' RegExpObj.Pattern = "[<>\'\;\%\&\/\\]"
' resultStr = RegExpObj.replace(checkStr, "")
' Set RegExpObj=Nothing
'
' resultStr =replace(resultStr,Chr("34"),"") '过滤"号
cCstr = checkStr
end if
end Function
function Replacestr(str) ' 增加一个字符串过滤函数,可以过滤特殊非法字符
Dim RegExpObj
Dim resultStr,checkStr
checkStr = str
if isnull (str) then
Replacestr = ""
else
' 剔除多余空格
do while Instr (checkStr, " " )
checkStr = Replace (checkStr, " " , " " ) ' 将两个连续的空格替换为一个空格
loop
resultStr = replace (checkStr, Chr ( " 34 " ), "" ) ' 过滤"号
resultStr = replace (resultStr, Chr ( " 60 " ), " 《 " ) ' 过滤<号
resultStr = replace (resultStr, Chr ( " 62 " ), " 》 " ) ' 过滤>号
resultStr = replace (resultStr, Chr ( " 38 " ), " and " ) ' 过滤&号
resultStr = replace (resultStr, Chr ( " 39 " ), " ‘ " ) ' 过滤'号
' resultStr =replace(resultStr,Chr("37"),"(百分比)") '过滤%号
Replacestr = resultStr
end if
end function
function cccur(strr) ' 自定义货币类型数据转换函数
dim str
str = cCstr(strr)
if isnull (str) or str = "" then
cccur = 0
else
str = replace (str, " ¥ " , "" )
str = replace (str, " $ " , "" )
if IsNumeric (str) then
' cccur=formatNumEx(str,"money")
cccur = Round (str, 2 )
else
cccur = 0
end if
end if
end function
function ccbool(str) ' 自定义bit bool 型数据转换函数
if isnull (str) or str = "" then
ccbool = false
Else
If " False " = str Or " True " = str Then
ccbool = cbool (str)
Else
if ccint(str) = 0 then
ccbool = false
elseif ccint(str) = 1 then
ccbool = True
Else
ccbool = cbool (str)
End if
End If
end if
end function
function fFormatNumber(str,t1,t2) ' 自定义格式化数字函数 t1 小数点后位数 t2 是否显示小数前的0
if isnull (str) or str = "" then str = 0
if IsNumeric (str) then
fFormatNumber = FormatNumber (str,ccint(t1),ccint(t2))
else
fFormatNumber = FormatNumber ( 0 ,ccint(t1),ccint(t2))
end if
end function
function fill_blank(str) ' 函数作用,对参数进行判断,如果为空或 null则返回 空格,这样来维护表格线的完整
if isnull (str) or str = "" then
fill_blank = " "
else
fill_blank = str
end if
end function
function fill_blank2(str) ' 函数作用,同上,此函数一般在会出现js中使用,因为 的 ;号,没有转义则不能正常显示
if isnull (str) or str = "" then
fill_blank2 = " "
else
fill_blank2 = str
end if
end function
Function long_check(info,s_num) ' 取定长字数函数, info需要进行截取的字符串,s_num截取得长度
if isnull (info) then info = ""
if len ( trim (info)) > ccint(s_num) then
long_check = left ( trim (info),ccint(s_num) - 2 ) & " .. "
else
long_check = trim (info)
end if
end Function
% >
<
%
function GetchinaMoney(a) ' 得到中文的大写货币
if a <> "" then
a = cccur(a)
a = abs (a)
' a 要转换成大写的金额
dim atoc ' 转换之后的值
Dim String1 ' 如下定义
Dim String2 ' 如下定义
Dim String3 ' 从原A值中取出的值
Dim I ' 循环变量
Dim J ' A的值乘以100的字符串长度
Dim Ch1 ' 数字的汉语读法
Dim Ch2 ' 数字位的汉字读法
Dim nZero ' 用来计算连续的零值是几个
String1 = " 零壹贰叁肆伍陆柒捌玖 "
String2 = " 万仟佰拾亿仟佰拾万仟佰拾元角分 "
nZero = 0
' response.write CStr(a * 100)
if a > 1000000000000 then
atoc = " 零元整 "
else
If InStr ( 1 , CStr (a * 100 ), " . " ) <> 0 Then
err.Raise 5000 , , " 此函数( AtoC() )只能转换小数点后有两位以内的数! "
End If
J = Len ( CStr (a * 100 ))
String2 = Right (String2, J) ' 取出对应位数的STRING2的值
For I = 1 To J
String3 = Mid (a * 100 , I, 1 ) ' 取出需转换的某一位的值
If I <> (J - 3 ) + 1 And I <> (J - 7 ) + 1 And I <> (J - 11 ) + 1 And I <> (J - 15 ) + 1 Then
If String3 = 0 Then
Ch1 = ""
Ch2 = ""
nZero = nZero + 1
ElseIf String3 <> 0 And nZero <> 0 Then
Ch1 = " 零 " & Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
Else
Ch1 = Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
End If
Else ' 该位是万亿,亿,万,元位等关键位
If String3 <> 0 And nZero <> 0 Then
Ch1 = " 零 " & Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
ElseIf String3 <> 0 And nZero = 0 Then
Ch1 = Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
ElseIf String3 = 0 And nZero >= 3 Then
Ch1 = ""
Ch2 = ""
nZero = nZero + 1
Else
Ch1 = ""
Ch2 = Mid (String2, I, 1 )
nZero = nZero + 1
End If
If I = (J - 11 ) + 1 Or I = (J - 3 ) + 1 Then ' 如果该位是亿位或元位,则必须写上
Ch2 = Mid (String2, I, 1 )
End If
End If
AtoC = AtoC & Ch1 & Ch2
If I = J And String3 = 0 Then ' 最后一位(分)为0时,加上“整”
AtoC = AtoC & " 整 "
End If
Next
if a = 0 then
atoc = " 零元整 "
end if
end if
GetchinaMoney = atoc
else
GetchinaMoney = ""
end if
end function
function Getchinanum(a) ' 得到中文的数字
if a <> "" then
a = ccint(a)
Dim String1 ' 如下定义
Dim String2 ' 如下定义
Dim String3 ' 从原A值中取出的值
Dim Ch ' 数字位的汉字
String1 = " 零一二三四五六七八九十 "
String2 = " 万千百十亿千百十万千百十 "
J = Len ( CStr (a))
ch = ""
For I = 1 To J
String3 = Mid (a, I, 1 ) ' 取出需转换的某一位的值
Ch = ch & Mid (String1, cint (String3) + 1 , 1 )
Next
Getchinanum = Ch
else
Getchinanum = ""
end if
end function
% >
function GetchinaMoney(a) ' 得到中文的大写货币
if a <> "" then
a = cccur(a)
a = abs (a)
' a 要转换成大写的金额
dim atoc ' 转换之后的值
Dim String1 ' 如下定义
Dim String2 ' 如下定义
Dim String3 ' 从原A值中取出的值
Dim I ' 循环变量
Dim J ' A的值乘以100的字符串长度
Dim Ch1 ' 数字的汉语读法
Dim Ch2 ' 数字位的汉字读法
Dim nZero ' 用来计算连续的零值是几个
String1 = " 零壹贰叁肆伍陆柒捌玖 "
String2 = " 万仟佰拾亿仟佰拾万仟佰拾元角分 "
nZero = 0
' response.write CStr(a * 100)
if a > 1000000000000 then
atoc = " 零元整 "
else
If InStr ( 1 , CStr (a * 100 ), " . " ) <> 0 Then
err.Raise 5000 , , " 此函数( AtoC() )只能转换小数点后有两位以内的数! "
End If
J = Len ( CStr (a * 100 ))
String2 = Right (String2, J) ' 取出对应位数的STRING2的值
For I = 1 To J
String3 = Mid (a * 100 , I, 1 ) ' 取出需转换的某一位的值
If I <> (J - 3 ) + 1 And I <> (J - 7 ) + 1 And I <> (J - 11 ) + 1 And I <> (J - 15 ) + 1 Then
If String3 = 0 Then
Ch1 = ""
Ch2 = ""
nZero = nZero + 1
ElseIf String3 <> 0 And nZero <> 0 Then
Ch1 = " 零 " & Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
Else
Ch1 = Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
End If
Else ' 该位是万亿,亿,万,元位等关键位
If String3 <> 0 And nZero <> 0 Then
Ch1 = " 零 " & Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
ElseIf String3 <> 0 And nZero = 0 Then
Ch1 = Mid (String1, clng (String3) + 1 , 1 )
Ch2 = Mid (String2, I, 1 )
nZero = 0
ElseIf String3 = 0 And nZero >= 3 Then
Ch1 = ""
Ch2 = ""
nZero = nZero + 1
Else
Ch1 = ""
Ch2 = Mid (String2, I, 1 )
nZero = nZero + 1
End If
If I = (J - 11 ) + 1 Or I = (J - 3 ) + 1 Then ' 如果该位是亿位或元位,则必须写上
Ch2 = Mid (String2, I, 1 )
End If
End If
AtoC = AtoC & Ch1 & Ch2
If I = J And String3 = 0 Then ' 最后一位(分)为0时,加上“整”
AtoC = AtoC & " 整 "
End If
Next
if a = 0 then
atoc = " 零元整 "
end if
end if
GetchinaMoney = atoc
else
GetchinaMoney = ""
end if
end function
function Getchinanum(a) ' 得到中文的数字
if a <> "" then
a = ccint(a)
Dim String1 ' 如下定义
Dim String2 ' 如下定义
Dim String3 ' 从原A值中取出的值
Dim Ch ' 数字位的汉字
String1 = " 零一二三四五六七八九十 "
String2 = " 万千百十亿千百十万千百十 "
J = Len ( CStr (a))
ch = ""
For I = 1 To J
String3 = Mid (a, I, 1 ) ' 取出需转换的某一位的值
Ch = ch & Mid (String1, cint (String3) + 1 , 1 )
Next
Getchinanum = Ch
else
Getchinanum = ""
end if
end function
% >