我在vb中用adodc连接ACCESS,下面这段函数是字符串匹配函数,语句和函数在ACCESS中测试没有问题,在程序中怎样作才能让这段函数起作用呢,哪位好心人帮帮忙给段代码,修改语句,使用函数都行,谢谢!测试通过小弟愿支付现金100元,具体事宜可回帖中商量,我的QQ41326168
执行语句:
SELECT * FROM CompareBase INNER JOIN Zd_WC2 ON AlikePercentEx(CompareBase.Xm_name,zd_WC2.WC_name)函数:
Public Function AlikePercentEx(ByVal strTextSrc As String, _
                                                            ByVal strTextDest As String, _
                                                            Optional ByVal blnCaseSensitive As Boolean = False, _
                                                            Optional ByVal blnExactPositionMatch As Boolean = False) As ADODB.Recordset
              
          Dim o_strTextSrc     As String
          Dim o_strTextDest     As String
              
          Dim o_strTextLonger     As String
          Dim o_strTextShorter     As String
              
          Dim o_strByteSrc     As String
          Dim o_strByteDest     As String
          Dim o_lngLength     As Long
          Dim o_lngItems     As Long
          Dim o_lngMatches     As Long
          Dim o_lngStart     As Long
           
          Dim con As ADODB.Connection
          Dim rs As ADODB.Recordset
          Dim strconnection As String
           
           Dim V_Str As String
           Set con = New ADODB.Connection
           Set rs = New ADODB.Record
           On Error GoTo AlikePercentEx
           cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\接口对应程序\Interface.mdb;Persist Security Info=False"
           
           
           
          If Not blnCaseSensitive Then
                  o_strTextSrc = UCase(strTextSrc)
                  o_strTextDest = UCase(strTextDest)
          Else
          End If
              
              
          If o_strTextSrc = o_strTextDest Then             '如果一致
                      
                  AlikePercentEx = 100#
              
          Else
              
                  If Len(o_strTextSrc) = Len(o_strTextDest) Then
                          o_strTextLonger = o_strTextSrc
                          o_strTextShorter = o_strTextDest
                  ElseIf Len(o_strTextSrc) > Len(o_strTextDest) Then
                          o_strTextLonger = o_strTextSrc
                          o_strTextShorter = o_strTextDest
                  Else
                          o_strTextLonger = o_strTextDest
                          o_strTextShorter = o_strTextSrc
                  End If
                                            
                   
                  o_lngLength = Len(o_strTextShorter)
                                      
                      
                  o_lngStart = InStr(o_strTextLonger, Left(o_strTextShorter, 1))
                      
                  If o_lngStart Then
                      
                          o_lngMatches = 1
                      
                          For o_lngItems = o_lngStart + 1 To Len(o_strTextLonger)
                                      
                                  If blnExactPositionMatch Then         '位置必须一致
                                          o_strByteSrc = Mid(o_strTextLonger, o_lngItems, 1)
                                          o_strByteDest = Mid(o_strTextShorter, o_lngItems - o_lngStart + 1, 1)
                                              
                                          If o_strByteSrc = o_strByteDest Then
                                                  o_lngMatches = o_lngMatches + 1
                                          Else
                                          End If
                                      
                                  Else     '任意位置模糊匹配
                                              
                                  End If
                          Next
                              
                          AlikePercentEx = (o_lngMatches / o_lngLength) * 100 \ 1
                              
                  Else
                              
                          AlikePercentEx = 0#
                  End If
                      
          End If
     
  End Function