金額小寫變大寫 VB版本

2021-06-16 01:01:59 字數 2079 閱讀 2812

'

'/ '/ 金額小寫變大寫

'/ '/

'/ public shared function gmoney(smallnum as decimal) as string

dim cmoney, cnumber, cnum, cnum_end, cmon, cno, snum, sno as string

dim snum_len, sint_len, cbegin, zflag, i as integer

if smallnum > 1000000000000.touint32() or smallnum < - 99999999999.touint32() or smallnum = 0 then

return ""

end if

cmoney = "仟佰拾億仟佰拾萬仟佰拾元角分" ' 大寫人民幣單位字串

cnumber = "壹貳叄肆伍陸柒捌玖" ' 大寫數字字串

cnum = "" ' 轉換後的大寫數字字串

cnum_end = "" ' 轉換後的大寫數字字串的最後一位

cmon = "" ' 取大寫人民幣單位字串中的某一位

cno = "" ' 取大寫數字字串中的某一位

snum = round(smallnum, 2).tostring("############.00") ' 小寫數字字串

snum_len = snum.length ' 小寫數字字串的長度

sint_len = snum_len - 2 ' 小寫數字整數部份字串的長度

sno = "" ' 小寫數字字串中的某個數字字元

cbegin = 15 - snum_len ' 大寫人民幣單位中的漢字位置

zflag = 1 ' 小寫數字字元是否為0(0=0)的判斷標誌

i = 0 ' 小寫數字字串中數字字元的位置

if snum_len > 15 then

return ""

end if

for i = 0 to snum_len - 1

if i = sint_len - 1 then

goto continuefor1

end if

cmon = cmoney.substring(cbegin, 1)

cbegin = cbegin + 1

sno = snum.substring(i, 1)

if sno = "-" then

cnum = cnum + "負"

goto continuefor1

else

if sno = "0" then

cnum_end = cnum.substring(cnum.length - 2, 1)

if cbegin = 4 or(cbegin = 8 or cnum_end.indexof("億") >= 0 or cbegin = 12) then

cnum = cnum + cmon

if cnumber.indexof(cnum_end) >= 0 then

zflag = 1

else

zflag = 0

end if

else

zflag = 0

end if

goto continuefor1

else

if sno <> "0" and zflag = 0 then

cnum = cnum + "零"

zflag = 1

end if

end if

end if

cno = cnumber.substring(system.convert.toint32(sno) - 1, 1)

cnum = cnum + cno + cmon

continuefor1:

next i

if snum.substring(snum.length - 2, 1) = "0" then

return cnum + "整"

else

return cnum

end if

end function 'gmoney

數字金額變大寫

public class class1 dim strbig 10 as string dim strunit 6 as string private function alltobig byval number as decimal as string try strbig 0 零 strbig ...

金額小寫轉大寫

create procedure dbo trannumbertobigfordecrypt n lowermoney numeric 15,2 v transtype int,ret varchar 200 output with encryption as descript 解密exec sp ...

金額小寫轉大寫

create procedure dbo trannumbertobigfordecrypt n lowermoney numeric 15,2 v transtype int,ret varchar 200 output with encryption as descript 解密exec sp ...