Transform the number of the renminbi into uppercase representation (VB.NET version) (former chenyu001c # version)

xiaoxiao2021-03-06  55

'Conversion of the number of the renminbi into uppercase representation (VB.NET version)

'This code reference chenyu001

'Conversion of the number of the renminbi into uppercase representation (C # version)

'http://dev.9cbs.net/Article/28/28977.shtm

'There are not many changes, I hope that these changes have not allowed the original author.

Public Class ChineseNum, PUBLIC CLASSENUM

'Input string

Private _inputstring as string

'Output string, if it is invalid, output an error message

Private_outstring as string

'Judging whether the output string is valid

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 converttochineseum ()

DIM NUMLIST AS STRING = "Zero Zibo Lu Lu Lu"

DIM RMBLIST AS STRING = "Practitioner Picture Pick up 100 million"

DIM NUMBER AS DOUBLE = 0

Dim TempoutString As String

Try

Number = double.parse (me._inputstring)

Catch ex as systemexception

Me._outstring = "Incoming parameters Non-numbers!"

Me._Valiad = false

Return

END TRY

IF Number> 9999999999999.99 THEN

Me._Valiad = false

Me._outstring = "Benefits Renminbi"

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

Dim OneNumber As INTEGER = INT32.PARS (TempNumBerstring.Substring (i, 1))

Dim OneNumberchar as string = Numlist.substring (OneNumber, 1)

Dim OneNumberunit As String = Rmblick (TempnmberLength - i - 1, 1)

IF not (Onenumberchar = "zero") THEN

TempoutString = Onenumberchar OneNumberunit

Else

If Onenumberunit = "100 million" oralse onenumberunit = "10,000" oralse oneNumberunit = "yuan" orelse onenumberunit = "zero" thenwhile tempoutstring.endswith ("zero")

TempoutString = TempoutString.substring (0, TempoutString.Length - 1)

End while

END IF

If OneNumberunit = "100 million" orelse (Onenumberunit = "Wan" Andalso Not TempoutString.eLse OneNumberunit = "Yuan" THEN

TempoutString = OneNumberUnit

Else

Dim Tempend as boolean = tempoutstring.endswith ("100 million")

Dim Zeroend As Boolean = TempoutString.endswith ("Zero")

IF TempoutString.Length> 1 THEN

Dim Zerostart As Boolean = TempoutString.Substring (TempoutString.Length - 2, 2) .StartSwith ("zero")

IF not Zeroend Andalso (Zerostart Oralse Not Tempend) THEN

TempoutString = Onenumberchar

END IF

Else

IF not zeroend andalso not tempend the

TempoutString = Onenumberchar

END IF

END IF

END IF

END IF

i = 1

End while

While TempoutString.endswith ("zero")

TempoutString = TempoutString.substring (0, TempoutString.Length - 1)

End while

While TempoutString.endswith ("Yuan")

TempoutString = TempoutString "whole"

End while

Me._outstring = TempoutString

Me._Valiad = True

End Sub

END CLASS

'

DIM M as new Chineseum

Private sub button1_click (byvale 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

转载请注明原文地址:https://www.9cbs.com/read-116969.html

New Post(0)