Ok here you go davio... Demo here.
Syntax CustomLeft(strToFilter, LengthReturned)
Dont go under 20 charecters to return... 20 is the minimum.
Function CustomLeft(fString, fLen)
if ((InStr(fString, "<")>0) and (InStr(fString, ">")>0) and len(fString)>fLen) Then
Dim strTemp, strTempcnt, strBrk1, strBrk2, strRemoved,tagCount
strTemp = fString
strTempcnt = 0
strRemoved = 0
tagCount = 0
Do While (InStr(1, strTemp, "<")>0) And (InStr(1, strTemp, ">")>0)
strBrk1 = InStr(1, strTemp, "<")
strBrk2 = InStr(1, strTemp, ">")-strBrk1
tagCount = tagCount + 1
strRemoved = strRemoved + Len(Mid(strTemp, strBrk1, strBrk2))
strTemp = Left(strTemp, Instr(1, strTemp, "<")-1) & Right(strTemp, Len(strTemp)-Instr(1,strTemp, ">"))
strTempcnt = Len(strTemp)
if (InStr(Left(strTemp, fLen), "<")<1) And (InStr(Left(StrTemp,fLen),">")<1) then
Exit Do
end if
Loop
if ((strTempcnt > fLen) and (strRemoved > 0)) then
LastChars = Right(Left(strTemp, ((fLen)+Cint(Instr(Mid(strTemp,(fLen),20)," ")))-1),5)
CustomLeft = Left(fString, InStr(fString, LastChars)+4) & "..."
elseif (strTempcnt > fLen) and (strRemoved < 1) then
CustomLeft = Left(fString, ((fLen)+Cint(Instr(Mid(fString,(fLen),20)," ")))-1) & "..."
else
CustomLeft = fString
end if
elseif len(fString)>fLen then
CustomLeft = Left(fString, ((fLen)+Cint(Instr(Mid(fString,(fLen),20)," ")))-1) & "..."
else
CustomLeft = fString
end if
End Function