CutString3

Cuts a string from a larger one using separators.
Ex, CutString3("Will you|read|my main|string?", 3, "|")
will return my main

Public
Tested
My Own Work
Function CutString3(CutFrom, iCutID, Optional Sepa ="{||}")
' In the Name of Allah
' Cut a specified string from a set of string seperated with a seperator
' Get the text with iRecord from sRecord based on its sequence in that text
If Sepa="" Then Sepa = "{||}"
NewCut = CutFrom & Sepa
Part1 = CutFrom
If iCutID > 0 Then
ThisID = 0
LastSepa = 1
FindSepa = InStr(LastSepa, NewCut, Sepa)
Do While FindSepa > 0
ThisID = ThisID + 1
If ThisID = iCutID Then
Part1 = Mid(NewCut, LastSepa, FindSepa - LastSepa)
Exit Do
Else
LastSepa = FindSepa + Len(Sepa)
End If
FindSepa = InStr(LastSepa, NewCut, Sepa)
Loop
End If
CutString3 = Part1
End Function

CutFrom, iCutID, Sepa

Views 3072 Downloads 1004

VBA Texts + Strings
ANmarAmdeen
629
Revisions

v1.0