|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Function FindStrPro(strObj As String, strSou As String, strLen As Integer) As String
Dim s(3) As String
Dim l(3) As Integer
s(3) = "*" & strObj & "*"
If strSou Like s(3) Then
Do
s(0) = strSou
l(0) = Len(s(0))
l(1) = Int(l(0) * 0.5 + 0.5)
l(2) = l(0) - l(1)
If l(2) > strLen Then
s(1) = Left(s(0), l(1))
s(2) = Right(s(0), l(2))
If s(1) Like s(3) Then
strSou = s(1)
ElseIf s(2) Like s(3) Then
strSou = s(2)
Else: strSou = Mid(s(0), l(1) - strLen + 1, strLen * 2 - 2)
Exit Do
End If
Else
Exit Do
End If
Loop
FindStrPro = FindStr(strObj, strSou, strLen)
Else: FindStrPro = ""
End If
End Function
Private Function FindStrPos(strObj As String, ByVal strSou As String, strLen As Integer) As Integer
Dim s1 As String
Dim s2 As String
s1 = strSou
s2 = FindStrPro(strObj, strSou, strLen)
If s2 <> "" Then
FindStrPos = InStr(s1, s2)
Else
FindStrPos = 0
End If
End Function |
|