注册 登录
Office中国论坛/Access中国论坛 返回首页

caisen的个人空间 http://www.office-cn.net/?20722 [收藏] [复制] [分享] [RSS]

日志

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

已有 1141 次阅读2012-5-17 16:08 | 计算, 公制

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

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-15 01:17 , Processed in 0.061775 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部