下面这段函数是字符串匹配的函数,在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
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
解决方案 »
- VB能不能做release版的exe
- winsock 接收网页编码为utf8格式 的问题
- 动态dim?redim?
- vb6.0操作EXCEL
- 关于Error: 「実行時エラー:'35601':要素が見つかりません。」
- 有在微软工作的吗? 想知道微软是如何制作 service pack 补丁包的?
- VB改写注册表问题
- 关于win98客户端连接win2000服务器数据库的问题。关键字:Ipc$ 权
- 会编程的高手帮帮忙,帮我编个小VB程序,万分感激
- 公用对话框的flag常数如cdlOFNAllowMultiselect如何查找?
- 读取文本文件与比较的问题【头都想大了!】
- 帮忙看一下,有没有比 do while.....loop更好的办法?
------------------------------------
一般调用:
call AlikePercentEx4("你的源字串","你的目的字串")如果希望大小写敏感比较:
call AlikePercentEx4("你的源字串","你的目的字串",true)如果希望精确位置匹配:
call AlikePercentEx4("你的源字串","你的目的字串",true,true)
dim aa#
aa=AlikePercentEx4("你的源字串","你的目的字串")
SELECT * FROM CompareBase INNER JOIN Zd_yp5 ON CompareBase.Xm_name,zd_yp5.yp_name麻烦大哥再给写段具体的吧
SELECT * FROM CompareBase INNER JOIN Zd_yp5 ON abc