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