欢迎光临
我们一直在努力

金额转换算法-ASP教程,ASP应用

建站超值云服务器,限时71元/月

private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click

dim str as string

str = me.textbox1.text.trim

dim isfs as boolean

if left(str, 1) = "-" then

isfs = true

str = str.remove(0, 1)

else

isfs = false

end if

dim strpoint as string

dim point() as string

dim j as int16

dim jj() as string

dim jjj as string

jjj = ""

if str.indexof(".") <> -1 then

point = split(str, ".", -1, comparemethod.text)

str = point(0)

strpoint = point(1)

redim jj(strpoint.length – 1)

for j = 0 to strpoint.length – 1

jj(j) = left(strpoint, 1)

strpoint = right(strpoint, strpoint.length – 1)

jjj = jjj + convert(jj(j))

next

end if

dim strcode as string

strcode = ""

while strcode.length <= str.length

strcode = strcode & "2345" & "2346"

end while

strcode = "1" & strcode

strcode = left(strcode, str.length)

dim i as int16

dim a() as string

dim strcode1 as string

dim countstr as int16

dim strcode2 as string

countstr = strcode.length

redim a(strcode.length – 1)

for i = 0 to countstr – 1

a(i) = right(strcode, 1)

strcode = left(strcode, strcode.length – 1)

strcode1 = strcode1 & a(i)

strcode2 = strcode2 & "," & mid(str, i + 1, 1) & mid(strcode1, i + 1, 1)

next

strcode2 = right(strcode2, strcode2.length – 1)

dim newstr() as string

newstr = split(strcode2, ",", -1, comparemethod.text)

dim ii as int16

dim laststr as string

dim strcode3 as string

dim leftstr as string

dim rightstr as string

for ii = 0 to newstr.length – 1

strcode3 = newstr(ii)

leftstr = left(strcode3, 1)

rightstr = right(strcode3, 1)

rightstr = replace(rightstr, rightstr, convert2(rightstr))

leftstr = replace(leftstr, leftstr, convert(leftstr))

if leftstr = "零" and (rightstr = "拾" or rightstr = "佰" or rightstr = "仟") then

rightstr = ""

end if

if leftstr = "零" and (rightstr = "万" or rightstr = "亿") then

leftstr = ""

end if

strcode3 = leftstr & rightstr

laststr = laststr & strcode3

next

while laststr.indexof("佰零万") <> -1

laststr = laststr.replace("零万", "万")

end while

while laststr.indexof("仟零零万") <> -1

laststr = laststr.replace("零零万", "万")

end while

while laststr.indexof("零万") <> -1

laststr = laststr.replace("零万", "零")

end while

while laststr.indexof("零亿") <> -1

laststr = laststr.replace("零亿", "亿")

end while

while laststr.indexof("零零") <> -1

laststr = laststr.replace("零零", "零")

end while

while right(laststr, 1) = "零"

laststr = left(laststr, laststr.length – 1)

end while

if isfs = true then

laststr = "负" & laststr

end if

if jjj = "" then

td2.innerhtml = laststr

else

if laststr = "" then

td2.innerhtml = "零点" & jjj

else

td2.innerhtml = laststr & "点" & jjj

end if

end if

end sub

function convert(byval num as string)

select case num

case "1"

convert = "壹"

case "2"

convert = "贰"

case "3"

convert = "叁"

case "4"

convert = "肆"

case "5"

convert = "伍"

case "6"

convert = "陆"

case "7"

convert = "柒"

case "8"

convert = "捌"

case "9"

convert = "玖"

case "0"

convert = "零"

end select

end function

function convert2(byval num as string)

select case num

case "1"

convert2 = ""

case "2"

convert2 = "拾"

case "3"

convert2 = "佰"

case "4"

convert2 = "仟"

case "5"

convert2 = "万"

case "6"

convert2 = "亿"

end select

end function

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 金额转换算法-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章