Ah, too long copy of Mid$ *facepalm*
Back to older thread...
strTest = DeleteBetween(DeleteBetween(TESTSTRING, " (", ")"), "(", ")")
Code:Public Function DeleteBetween(ByVal sText As String, sBefore As String, sAfter As String) As String Dim P1 As Long, P2 As Long, L As Long, T As Long Dim L1 As Long: L1 = LenB(sBefore) Dim L2 As Long: L2 = LenB(sAfter) If LenB(sText) = 0 Or L1 = 0 Or L2 = 0 Then Exit Function P2 = 1 - L2 Do P2 = P2 + L2: P1 = P2 - 1 Do: P1 = InStrB(P1 + 1, sText, sBefore) Loop While (P1 And 1) = 0 And (P1 > 0) If P1 = 0 Then P1 = LenB(sText) + 1 L = P1 - P2 If L Then MidB$(sText, T + 1, L) = MidB$(sText, P2, L) T = T + L P2 = P1 + L1 - 1 Do: P2 = InStrB(P2 + 1, sText, sAfter) Loop While (P2 And 1) = 0 And (P2 > 0) Loop While P2 If T Then DeleteBetween = LeftB$(sText, T) End Function




Reply With Quote