2009年2月24日 星期二

數字轉國字大寫

改以mid函數及迴路處理

image

'數字轉國字大寫
'改以mid函數及迴路處理

Public Class Form1
    Dim i
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim r1 = "0123456789"
        Dim r2 = "零壹貳参肆伍陸柒捌玖"
        Dim d = "135897"
        Dim s = d
        's = Replace(s, "1", "壹")
        's = Replace(s, "2", "貳")
        's = Replace(s, "3", "参")
        's = Replace(s, "4", "肆")
        's = Replace(s, "5", "伍")
        's = Replace(s, "6", "陸")
        's = Replace(s, "7", "柒")
        's = Replace(s, "8", "捌")
        's = Replace(s, "9", "玖")
        's = Replace(s, "0", "零")

        For i = 1 To 10
            s = Replace(s, Mid(r1, i, 1), Mid(r2, i, 1))
        Next i

        MsgBox(d & " 國字大寫為:" & s)
    End Sub
End Class

沒有留言:

張貼留言