国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阜平县| 漳浦县| 中江县| 合水县| 拉孜县| 军事| 枝江市| 桑日县| 九江市| 康保县| 三原县| 门头沟区| 吉水县| 巫溪县| 南华县| 同德县| 茌平县| 商城县| 浦城县| 集安市| 太康县| 洛南县| 衡山县| 富源县| 新野县| 博客| 弥勒县| 靖边县| 东丰县| 资兴市| 安康市| 九寨沟县| 中超| 同仁县| 漳浦县| 澄江县| 清徐县| 财经| 大宁县| 沅陵县| 武隆县|