Поиск и Замена в строкеВстроенная функция от MS: Replace("СТРОКА В КОТОРОЙ ИЩЕМ И МЕНЯЕМ", "что меняем", "на что меняем") Подробности: https://msdn.microsoft.com/ru-ru/library/bt3szac5%28v=vs.90%29.aspx Function FuncReplace(S As String, L As String) As String Do Until Len(S) = Len(Replace(S, L & L, L)) S = Replace(S, L & L, L) Loop FuncReplace = S End Function
Public Function ReplaceInStr(strString As String, strFind As String, strReplace As String) As String 'es 27.07.2012 'Поиск и замена в тексте - Возвращает модифицированный текст ... '-------------------------------------------------------------------------- 'Аргументы ' strString = Тект ' strFind = Что Ищем ' strReplace = На что меняем '-------------------------------------------------------------------------- Dim strFirst As String, strLast As String, strOut As String, intPos As Long On Error GoTo ReplaceInStrErr strOut = strString If strFind = "" Then GoTo ReplaceInStrBye If strFind = strReplace Then GoTo ReplaceInStrBye intPos = InStr(strOut, strFind) Do Until intPos = 0 strFirst = Mid$(strOut, 1, intPos - 1) strLast = Mid$(strOut, intPos + Len(strFind)) strOut = strFirst & strReplace & strLast intPos = InStr(intPos + Len(strReplace), strOut, strFind) Loop ReplaceInStrBye: ReplaceInStr = strOut Exit Function ReplaceInStrErr: 'MsgBox "Error " & Err.Number & " (" & Err.Description & ")" & vbCrLf & _ "in procedure ReplaceInStr of Module modBuildInField", vbCritical, "Error!" Err.Clear strOut = strString 'Отмена Resume ReplaceInStrBye End Function |
|||
L.E. 22.12.2017 |