|
|
Очистка текста от спецсимволов и прочего для использования при поиске
Public Function ClearSearchString(vVal As Variant) As String
Dim i As Integer
Dim iAsc As Integer
Dim sMid As String * 1
Dim siLen As Integer
Dim strNew As String
On Error GoTo ClearSearchString_Err
strNew = CStr(vVal)
strNew = Trim(strNew)
strNew = Replace(strNew, " ", " ")
strNew = Replace(strNew, " ", " ")
siLen = Len(strNew)
For i = 1 To siLen
sMid = Mid(strNew, i, 1)
iAsc = Asc(sMid)
Select Case iAsc
Case 0 To 31: sMid = ""
Case 32, 33: sMid = sMid
Case 34: sMid = ""
Case 35: sMid = sMid
Case 38, 39: sMid = "?"
Case 42: sMid = sMid
Case 43 To 45: sMid = ""
Case 58 To 62: sMid = ""
Case 123 To 126: sMid = ""
Case 127: sMid = ""
Case 171, 187: sMid = ""
End Select
ClearSearchString = ClearSearchString & sMid
Next i
ClearSearchString = Replace(ClearSearchString, " ", " ")
ClearSearchString = Replace(ClearSearchString, " *", "*")
ClearSearchString = Replace(ClearSearchString, "* ", "*")
ClearSearchString_End:
On Error Resume Next
Err.Clear
Exit Function
ClearSearchString_Err:
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in Function: ClearSearchString in module: 00_Tests", vbCritical, "Error in Application"
Err.Clear
Resume ClearSearchString_End
End Function
|
|