CutString3

Cuts string from a larger one based on a specific separator.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function CutString3(InString, CutID, 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
Dim NewCut = InString & Sepa
Dim Part1 = InString
If CutID > 0 Then
Dim ThisID = 0
Dim LastSepa = 1
Dim FindSepa = InStr(LastSepa, NewCut, Sepa)
Do While FindSepa > 0
ThisID = ThisID + 1
If ThisID = CutID 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

InString, CutID, Sepa

CutString3("Will you|read|my main|string?", 2, "|") will return read

Views 4,921

Downloads 1,483

CodeID
DB ID