下面这段函数是字符串匹配的函数,在access中测试没有问题,怎样在vb中使用呢,哪位好心人帮帮忙,尽量说祥细一点,我的水平很烂的, Public Function AlikePercentEx4(ByVal strTextSrc As String, _ 
                                                            ByVal strTextDest As String, _ 
                                                            Optional ByVal blnCaseSensitive As Boolean = False, _ 
                                                            Optional ByVal blnExactPositionMatch As Boolean = False) As Double 
             
          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 
             
          If Not blnCaseSensitive Then 
                  o_strTextSrc = UCase(strTextSrc) 
                  o_strTextDest = UCase(strTextDest) 
          Else 
          End If 
             
             
          If o_strTextSrc = o_strTextDest Then            '如果一致 
                     
                  AlikePercentEx4 = 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, 4)) 
                     
                  If o_lngStart Then 
                     
                          o_lngMatches = 4 
                     
                          For o_lngItems = o_lngStart + 4 To Len(o_strTextLonger) 
                                     
                                  If blnExactPositionMatch Then        '位置必须一致 
                                          o_strByteSrc = Mid(o_strTextLonger, o_lngItems, 4) 
                                          o_strByteDest = Mid(o_strTextShorter, o_lngItems - o_lngStart + 4, 4) 
                                             
                                          If o_strByteSrc = o_strByteDest Then 
                                                  o_lngMatches = o_lngMatches + 4 
                                          Else 
                                          End If 
                                     
                                  Else    '任意位置模糊匹配 
                                             
                                             
                                  End If 
                          Next 
                             
                          AlikePercentEx4 = (o_lngMatches / o_lngLength) * 100 \ 4 
                             
                  Else 
                             
                          AlikePercentEx4 = 0# 
                  End If 
                     
          End If 
    
  End Function 

解决方案 »

  1.   

    前两个字串形参必选,后两个可选
    ------------------------------------
    一般调用:
    call AlikePercentEx4("你的源字串","你的目的字串")如果希望大小写敏感比较:
    call AlikePercentEx4("你的源字串","你的目的字串",true)如果希望精确位置匹配:
    call AlikePercentEx4("你的源字串","你的目的字串",true,true)
      

  2.   

    也可以:
    dim aa#
    aa=AlikePercentEx4("你的源字串","你的目的字串") 
      

  3.   

    还是不行,这是执行语句
    SELECT * FROM CompareBase INNER JOIN Zd_yp5 ON CompareBase.Xm_name,zd_yp5.yp_name麻烦大哥再给写段具体的吧
      

  4.   

    abc=AlikePercentEx4("XXXXX","YYYYY")
    SELECT * FROM CompareBase INNER JOIN Zd_yp5 ON abc