CutString3

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


Public

Tested

My Own 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 3449 Downloads 1066

VB.Net Texts + Strings
ANmarAmdeen
642
Revisions

v1.0