会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛

access数字转英文大写示例源码

时间:2014-02-08 16:14 来源:office中国 作者:宿命的风 阅读:
软件类型:国产软件 授权方式:免费软件 界面语言:简体中文 软件大小:425 KB 文件类型:.rar 运行环境:Win2003,WinXP,Win7,win8 软件等级:★★★★★ 发布时间:2014-02-08 插件情况:无插件,请放心使用。 下载次数:
软件介绍:
    阿拉伯数字转英文,数字转中文数字,中文数字转大写数字。这些我们转换我们会经常用到。特别是会计财务行业。
    下面的示例是一个自定义函数,数字(整数)转英文大写:数量转为英文数量,金额转为英文金额。

Function SpellNumber(ByVal MyNumber)
    Dim Dollars, Cents, Temp
    Dim DecimalPlace, Count
    ReDim Place(9) As String
    Place(2) = " Thousand "
    Place(3) = " Million "
    Place(4) = " Billion "
    Place(5) = " Trillion "
    ' String representation of amount.
    MyNumber = Trim(Str(MyNumber))
    ' Position of decimal place 0 if none.
    DecimalPlace = InStr(MyNumber, ".")
    ' Convert cents and set MyNumber to dollar amount.
    If DecimalPlace > 0 Then
        Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
                  "00", 2))
        MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
    End If
    Count = 1
    Do While MyNumber <> ""
        Temp = GetHundreds(Right(MyNumber, 3))
        If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
        If Len(MyNumber) > 3 Then
            MyNumber = Left(MyNumber, Len(MyNumber) - 3)
        Else
            MyNumber = ""
        End If
        Count = Count + 1
    Loop
    Select Case Dollars
        Case ""
            Dollars = "No Amount "
        Case "One"
            Dollars = "One"
         Case Else
            Dollars = Dollars
    End Select
    Select Case Cents
        Case ""
            Cents = " and No Cents"
        Case "One"
            Cents = " and One Cent"
              Case Else
            Cents = " and " & Cents & " Cents"
    End Select
    SpellNumber = Dollars & Cents
    
End Function</P>
<P>' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
    Dim Result As String
    If Val(MyNumber) = 0 Then Exit Function
    MyNumber = Right("000" &amp; MyNumber, 3)
    ' Convert the hundreds place.
    If Mid(MyNumber, 1, 1) &lt;&gt; "0" Then
        Result = GetDigit(Mid(MyNumber, 1, 1)) &amp; " Hundred "
    End If
    ' Convert the tens and ones place.
    If Mid(MyNumber, 2, 1) &lt;&gt; "0" Then
        Result = Result &amp; GetTens(Mid(MyNumber, 2))
    Else
        Result = Result &amp; GetDigit(Mid(MyNumber, 3))
    End If
    GetHundreds = Result
End Function</P>
<P>' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
    Dim Result As String
    Result = ""           ' Null out the temporary function value.
    If Val(Left(TensText, 1)) = 1 Then   ' If value between 10-19...
        Select Case Val(TensText)
            Case 10: Result = "Ten"
            Case 11: Result = "Eleven"
            Case 12: Result = "Twelve"
            Case 13: Result = "Thirteen"
            Case 14: Result = "Fourteen"
            Case 15: Result = "Fifteen"
            Case 16: Result = "Sixteen"
            Case 17: Result = "Seventeen"
            Case 18: Result = "Eighteen"
            Case 19: Result = "Nineteen"
            Case Else
        End Select
    Else                                 ' If value between 20-99...
        Select Case Val(Left(TensText, 1))
            Case 2: Result = "Twenty "
            Case 3: Result = "Thirty "
            Case 4: Result = "Forty "
            Case 5: Result = "Fifty "
            Case 6: Result = "Sixty "
            Case 7: Result = "Seventy "
            Case 8: Result = "Eighty "
            Case 9: Result = "Ninety "
            Case Else
        End Select
        Result = Result &amp; GetDigit _
            (Right(TensText, 1))  ' Retrieve ones place.
    End If
    GetTens = Result
End Function</P>
<P>' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
    Select Case Val(Digit)
        Case 1: GetDigit = "One"
        Case 2: GetDigit = "Two"
        Case 3: GetDigit = "Three"
        Case 4: GetDigit = "Four"


数字转英文自定义函数
http://www.office-cn.net/forum.php?mod=viewthread&tid=33428
顶一下
(1)
50%
踩一下
(1)
50%
下载地址:
注意事项:

☉推荐使用第三方专业下载工具下载本站软件,使用 WinRAR v3.10 以上版本解压本站软件。
☉如果这个软件总是不能下载的请点击报告错误,谢谢合作!!
☉下载本站资源,如果服务器暂不能下载请过一段时间重试!
☉如果遇到什么问题,请到本站论坛去咨寻,我们将在那里提供更多 、更好的资源!
☉本站提供的一些商业软件是供学习研究之用,如用于商业用途,请购买正版。

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: