Converts a digital representation of the renminbi into a capital representation (VB). NET edition)
Last Update:2017-02-28
Source: Internet
Author: User
Capital | Renminbi ' converts the digital representation of the renminbi into a capital representation (VB. NET edition)
' This Code reference chenyu001
' Convert a digital representation of the renminbi into a capital letter (C # Edition)
' Http://dev.csdn.net/article/28/28977.shtm
' Not much, I hope these changes do not make the original author angry
Public Class Chinesenum
' Input string
Private _inputstring as String
' Output string, output error message if invalid
Private _outstring as String
' Determine if 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 Converttochinesenum ()
Dim numlist as String = "0 Woolu qi ba Nine"
Dim rmblist as String = "penny-picking hundred thousand thousand hundred thousand million"
Dim number as Double = 0
Dim tempoutstring as String
Try
Number = Double.Parse (me._inputstring)
Catch ex As SystemException
me._outstring = "Incoming parameter not a number!" "
Me._valiad = False
Return
End Try
If number > 9999999999999.99 Then
Me._valiad = False
me._outstring = "The value of the people beyond the scope"
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 = "0") Then
Tempoutstring + + Onenumberchar + onenumberunit
Else
If onenumberunit = "billion" OrElse Onenumberunit = "million" OrElse Onenumberunit = "Yuan" OrElse onenumberunit = "0" Then
While Tempoutstring.endswith ("0")
tempoutstring = tempoutstring.substring (0, Tempoutstring.length-1)
End While
End If
If onenumberunit = "billion" OrElse (Onenumberunit = "million" AndAlso not Tempoutstring.endswith ("billion")) OrElse onenumberunit = "Yuan" the N
Tempoutstring + + Onenumberunit
Else
Dim tempend as Boolean = Tempoutstring.endswith ("billion")
Dim zeroend as Boolean = Tempoutstring.endswith ("0")
If tempoutstring.length > 1 Then
Dim Zerostart as Boolean = Tempoutstring.substring (tempoutstring.length-2, 2). StartsWith ("0")
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 ("0")
tempoutstring = tempoutstring.substring (0, Tempoutstring.length-1)
End While
While Tempoutstring.endswith ("meta")
tempoutstring = tempoutstring + "whole"
End While
me._outstring = tempoutstring
Me._valiad = True
End Sub
End Class
' The test method
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