|
|
Часть строки между заданнами образцами текста
Private Function GetStringBetweenStrings(StringToBeSeached As String, StartString As String, EndString As String)
Dim StartPos As Long
Dim EndPos As Long
StartPos = InStr(1, StringToBeSeached, StartString) + Len(StartString)
EndPos = InStr(StartPos, StringToBeSeached, EndString)
GetStringBetweenStrings = Mid(StringToBeSeached, StartPos, EndPos - StartPos)
End Function
Пример эксплуотации:
Private Sub Test_001()
Dim strMailMessage As String
Dim strRes As String
strMailMessage = "Bla - Bla - Bla " & vbCrLf & vbCrLf & vbCrLf & "First name:" & _
vbCrLf & vbCrLf & "Phil" & vbCrLf & "GOGO" & vbCrLf & vbCrLf & "Last name:"
strRes = Replace(GetStringBetweenStrings(strMailMessage, "First name:", "Last name:"), vbCrLf, " ")
strRes = Replace(Trim(strRes), " ", " ")
Debug.Print strRes
End Sub
|
|