This code was written by Toby Gramm, webmaster of Techfools.com.
Search And Kill!
Function SearchAndKill(s, s1, s2)
's The string to parse
's1 Starting Character or String
's2 Ending Character or String
'Example:
' MyCleanString = SearchAndKill("#crap$ Hi I'm a Tech Fool #more crap$","#","$")
'
'Returns this:
' " Hi I'm a Tech Fool "
'
Dim I
Dim iPos
Dim iPosEnd
Dim sProduct
Dim iLength
iPos = InStr(s, s1)
If iPos > 0 Then
iPosEnd = InStr(iPos, s, s2)
Else
Exit Function
End If
If Not iPosEnd > 0 Then Exit Function
iPosEnd = 1
Do While True
iPos = InStr(s, s1) + Len(s1)
If Not iPos > Len(s1) Then Exit Do
iPosEnd = InStr(iPos, s, s2) + len(s2) -1
iLength = iPosEnd - iPos
If Not iPosEnd > 0 Then iLength = Len(s)
If s1 = "" Then
iPos = 0
Else
iPos = iPos - (Len(s1) + 1)
End If
If s2 = "" Then
iPosEnd = Len(s)
Else
iPosEnd = Len(s) - iPosEnd
End If
sProduct = Left(s, iPos) & Right(s, iPosEnd)
s = sProduct
If InStr(s, s1) = 0 And InStr(s, s2) = 0 Then Exit Do
Loop
SearchAndKill = sProduct
End Function
Email: Toby Gramm




