Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

应用于计算公制方法,把字符公制,如:23 7/8转换成英寸数字方法

时 间:2012-05-17 15:52:55
作 者:李财盛   ID:20277  城市:东莞
摘 要:'===============================
'应用于计算公制方法,把字符公制,如:23 7/8转换成英寸数字方法
'编写于:2012-05-17   add:LCS
'调用:  变量= F_GZ("23  7/8")
'===================================

正 文:

Option Compare Database
'=========================================================
'应用于计算公制方法,把字符公制,如:23 7/8转换成英寸数字方法
'编写于:2012-05-17   add:LCS
'调用:  变量= F_GZ("23  7/8")
'=========================================================

Public Function F_GZ(ByVal LWStr As String) As Currency
    Dim SFIX As Double
    Dim Leftint As Currency, leftstr As String
    Dim rightint As Currency, rightstr As String
   
    Dim S() As String
REM_S:
    S = Split(RTrim(LTrim(LWStr)), " ")
    Dim I As Long, J As Long
    J = 0
    Dim SSTR As String
    SSTR = LTrim(RTrim(LWStr))
    If UBound(S) > 1 Then
        For I = 1 To LenB(LWStr)
            If Mid(SSTR, I, 1) = " " And J = 0 Then
                J = I
                Exit For
            End If
        Next I
        LWStr = Mid(SSTR, 1, J) & Replace(SSTR, " ", "", J + 1)
        GoTo REM_S
    End If
    Dim CRS As New ADODB.Recordset
    If UBound(S) = 1 Then
        Leftint = CCur(S(0))
        CRS.CursorLocation = adUseClient
        CRS.Open "Select " & S(1) & "", CurrentProject.Connection, adOpenKeyset, adLockReadOnly
        rightint = Nz(CRS.Fields(0), 0)
        CRS.Close
        Set CRS = Nothing
       
        F_GZ = Leftint + rightint
         'FRMNAME.Controls(Frmfields) = F_GZ
    ElseIf UBound(S) = 0 Then
         Leftint = CCur(S(0))
         F_GZ = Leftint
         'FRMNAME.Controls(Frmfields) = F_GZ
    Else
   
    End If
End Function



Access软件网QQ交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助