国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

將人民幣的數字表示轉化成大寫表示(VB.NET版)

2024-07-10 13:01:13
字體:
來源:轉載
供稿:網友
'將人民幣的數字表示轉化成大寫表示(vb.net版)

'本代碼參考chenyu001

'將人民幣的數字表示轉化成大寫表示(c#版)

'http://dev.csdn.net/article/28/28977.shtm

'改的不多,但愿這些改動沒讓原作者發怒

public class chinesenum

'輸入字串

private _inputstring as string

'輸出字串,如果無效則輸出錯誤信息

private _outstring as string

'判斷輸出字串是否有效

private _valiad as boolean



public writeonly property inputstring() as string

set(byval value as string)

_inputstring = value

converttochinesenum()

end set

end property

public readonly property valiad() as boolean

get

return _valiad

end get

end property

public readonly property outstring() as string

get

return _outstring

end get

end property

private sub converttochinesenum()

dim numlist as string = "零壹貳叁肆伍陸柒捌玖"

dim rmblist as string = "分角元拾佰仟萬拾佰仟億拾佰仟萬"

dim number as double = 0

dim tempoutstring as string

try

number = double.parse(me._inputstring)

catch ex as systemexception

me._outstring = "傳入參數非數字!"

me._valiad = false

return

end try

if number > 9999999999999.99 then

me._valiad = false

me._outstring = "超出范圍的人民幣值"

return

end if

dim tempnumberstring as string = convert.toint64(number * 100).tostring()

dim tempnmberlength as integer = tempnumberstring.length

dim i as integer = 0

while i < tempnmberlength

dim onenumber as integer = int32.parse(tempnumberstring.substring(i, 1))

dim onenumberchar as string = numlist.substring(onenumber, 1)

dim onenumberunit as string = rmblist.substring(tempnmberlength - i - 1, 1)

if not (onenumberchar = "零") then

tempoutstring += onenumberchar + onenumberunit

else

if onenumberunit = "億" orelse onenumberunit = "萬" orelse onenumberunit = "元" orelse onenumberunit = "零" then

while tempoutstring.endswith("零")

tempoutstring = tempoutstring.substring(0, tempoutstring.length - 1)

end while

end if

if onenumberunit = "億" orelse (onenumberunit = "萬" andalso not tempoutstring.endswith("億")) orelse onenumberunit = "元" then

tempoutstring += onenumberunit

else

dim tempend as boolean = tempoutstring.endswith("億")

dim zeroend as boolean = tempoutstring.endswith("零")

if tempoutstring.length > 1 then

dim zerostart as boolean = tempoutstring.substring(tempoutstring.length - 2, 2).startswith("零")

if not zeroend andalso (zerostart orelse not tempend) then

tempoutstring += onenumberchar

end if

else

if not zeroend andalso not tempend then

tempoutstring += onenumberchar

end if

end if

end if

end if

i += 1

end while

while tempoutstring.endswith("零")

tempoutstring = tempoutstring.substring(0, tempoutstring.length - 1)

end while

while tempoutstring.endswith("元")

tempoutstring = tempoutstring + "整"

end while

me._outstring = tempoutstring

me._valiad = true

end sub

end class



'則試方法

dim m as new chinesenum

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

m.inputstring = me.textbox1.text

if m.valiad then

me.textbox2.text = m.outstring

me.textbox3.text = string.empty

else

me.textbox2.text = string.empty

me.textbox3.text = m.outstring

end if

end sub

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彰武县| 始兴县| 乌鲁木齐县| 永吉县| 类乌齐县| 伽师县| 三亚市| 陇川县| 宁夏| 南华县| 二连浩特市| 荆门市| 桑日县| 怀来县| 兴海县| 荣昌县| 冷水江市| 青州市| 逊克县| 库车县| 重庆市| 博兴县| 保德县| 修武县| 花莲市| 洛宁县| 三都| 黑河市| 溆浦县| 南江县| 徐闻县| 扶沟县| 宁明县| 东山县| 耿马| 鸡东县| 会泽县| 正宁县| 玉屏| 吴堡县| 荔波县|