Converts a digital representation of the renminbi into a capital representation (VB). NET edition)

Source: Internet
Author: User
Tags integer
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.