以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 阿拉伯数字转汉字小写格式  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=76401)

--  作者:lsy
--  发布时间:2015/10/28 13:55:00
--  [求助] 阿拉伯数字转汉字小写格式
MessageBox.Show(CUNum(123)) :壹贰叁
MessageBox.Show(CUNumBer(123)):壹佰贰拾叁
MessageBox.Show(CLNum(123)):一二三

没有对应的CLNumber,要将123转成一百二十三,用什么函数呢?



--  作者:大红袍
--  发布时间:2015/10/28 14:07:00
--  

直接替换,如

 

MessageBox.Show(CUNumBer(123).replace("", "一").replace("佰", "百").replace("贰","二"))


--  作者:lsy
--  发布时间:2015/10/28 14:10:00
--  
以下是引用大红袍在2015/10/28 14:07:00的发言:

直接替换,如

 

MessageBox.Show(CUNumBer(123).replace("", "一").replace("佰", "百").replace("贰","二"))



谢谢!

也是个变通的法子。


--  作者:lsy
--  发布时间:2015/10/28 15:04:00
--  
Dim t As Table = CurrentTable
Dim result As String

For i As Integer = 0 To t.Rows.Count - 1
    Dim str1 As String = "壹贰叁肆伍陆柒捌玖仟佰拾零"
    Dim str2 As String = "一二三四五六七八九千百十〇"
    result = CUNumBer(i + 1)
    For j As Integer = 0 To str1.Length - 1
        result = result.Replace(str1(j), str2(j))
    Next
    If i + 1 < 20 AndAlso result.StartsWith("一十") Then
        result = result.SubString(1)
    End If
    t.Rows(i)("列名") = "第" & result & "列"    
Next