將金額的小寫轉換成大寫(VB.NET)....

Public Class Form1

    Inherits System.Windows.Forms.Form

 

 

#Region " Windows Form Designer generated code "

 

 

    Public Sub New()

        MyBase.New()

 

 

        'This call is required by the Windows Form Designer.

        InitializeComponent()

 

 

        'Add any initialization after the InitializeComponent() call

 

 

    End Sub

 

 

    'Form overrides dispose to clean up the component list.

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (components Is Nothing) Then

                components.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub

 

 

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

 

 

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer. 

    'Do not modify it using the code editor.

    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox

    Friend WithEvents Button1 As System.Windows.Forms.Button

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        Me.TextBox1 = New System.Windows.Forms.TextBox

        Me.TextBox2 = New System.Windows.Forms.TextBox

        Me.Button1 = New System.Windows.Forms.Button

        Me.SuspendLayout()

        '

        'TextBox1

        '

        Me.TextBox1.Location = New System.Drawing.Point(6, 8)

        Me.TextBox1.Name = "TextBox1"

        Me.TextBox1.Size = New System.Drawing.Size(226, 20)

        Me.TextBox1.TabIndex = 0

        Me.TextBox1.Text = ""

        '

        'TextBox2

        '

        Me.TextBox2.Location = New System.Drawing.Point(4, 38)

        Me.TextBox2.Name = "TextBox2"

        Me.TextBox2.Size = New System.Drawing.Size(228, 20)

        Me.TextBox2.TabIndex = 1

        Me.TextBox2.Text = ""

        '

        'Button1

        '

        Me.Button1.Location = New System.Drawing.Point(270, 34)

        Me.Button1.Name = "Button1"

        Me.Button1.TabIndex = 2

        Me.Button1.Text = "轉換"

        '

        'Form1

        '

        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

        Me.ClientSize = New System.Drawing.Size(354, 63)

        Me.Controls.Add(Me.Button1)

        Me.Controls.Add(Me.TextBox2)

        Me.Controls.Add(Me.TextBox1)

        Me.Name = "Form1"

        Me.Text = "Form1"

        Me.ResumeLayout(False)

 

 

    End Sub

 

 

#End Region

 

 

    Private istg_int_chinese_part As String

    Private istg_dec_chinese_part As String

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.NumberChangeChineseNumber(Me.TextBox1.Text)

        Me.TextBox2.Text = istg_int_chinese_part & Me.istg_dec_chinese_part

    End Sub

 

 

    Public Function NumberChangeChineseNumber(ByVal adel_input_number As Decimal)

        Dim lstg_number As String = "0123456789"

        Dim lstg_chinese_number As String = "零壹贰叁肆伍陆柒捌玖"

        Dim lstg_input_number As String = adel_input_number.ToString()

        Dim lint_point As Integer = lstg_input_number.IndexOf(".")

 

 

        Dim lstg_int_number As String = ""

        Dim lstg_int_number_digital As String = ""

        Dim lstg_int_chinese_digital As String = ""

 

 

        Dim lstg_number_digital As String = ""

 

 

        Dim lstg_dec_number As String = ""

        Dim lstg_dec_number_digital As String = ""

        Dim lstg_dec_chinese_digital As String = ""

 

 

        Dim lint_int_chinese_number As Integer

        Dim lint_dec_chinese_number As Integer

 

 

 

 

        If lint_point <> -1 Then

            Dim larr_don As String = "."

            Dim larr_char As Char() = larr_don.ToCharArray()

            Dim larr_input_number As String() = lstg_input_number.Split(larr_char)

            lstg_int_number = larr_input_number(0)

            lstg_dec_number = larr_input_number(1)

        Else

            lstg_int_number = lstg_input_number.ToString()

            lstg_dec_number = "00"

        End If

 

 

        If lstg_int_number.Length > 16 Then

            MessageBox.Show("數值超出范圍....")

        Else

            For lint_a As Integer = 1 To lstg_int_number.Length

                lstg_number_digital = lstg_int_number.Substring(lint_a - 1, 1)

 

 

                For lint_b As Integer = 0 To 9

                    lstg_int_number_digital = lstg_number.Substring(lint_b, 1)

                    lstg_int_chinese_digital = lstg_chinese_number.Substring(lint_b, 1)

                    If lstg_number_digital = lstg_int_number_digital Then

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part + lstg_int_chinese_digital

                    End If

                Next

 

 

                lint_int_chinese_number = lstg_int_number.Length - lint_a + 1

                Select Case lint_int_chinese_number

                    Case 1

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 2

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 3

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 4

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 5

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 6

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 7

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 8

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 9

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 10

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 11

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 12

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                    Case 13

                        Me.istg_int_chinese_part = Me.istg_int_chinese_part & ""

                End Select

            Next

 

 

            lstg_number_digital = ""

            For lint_aa As Integer = 1 To lstg_dec_number.Length

                lstg_number_digital = lstg_dec_number.Substring(lint_aa - 1, 1)

                For lint_bb As Integer = 0 To 9

                    lstg_dec_number_digital = lstg_number.Substring(lint_bb, 1)

                    lstg_dec_chinese_digital = lstg_chinese_number.Substring(lint_bb, 1)

                    If lstg_number_digital = lstg_dec_number_digital Then

                        Me.istg_dec_chinese_part = Me.istg_dec_chinese_part + lstg_dec_chinese_digital

                    End If

                Next

 

 

                lint_dec_chinese_number = lstg_dec_number.Length - lint_aa + 1

                Select Case lint_dec_chinese_number

                    Case 2

                        Me.istg_dec_chinese_part = Me.istg_dec_chinese_part & ""

                    Case 1

                        Me.istg_dec_chinese_part = Me.istg_dec_chinese_part & ""

                End Select

            Next

        End If

 

 

    End Function

End Class

 運行效果圖:

Number_ChangeTo_ChineseNumber...

posted on 2005-03-11 18:56  封起De日子  阅读(151)  评论(0编辑  收藏  举报

导航