View Single Post
  #31   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Fast way to truncate string

I was able to duplicate the exception by using a word that wasn't in
the string being truncated. That precludes that you need to know the
contents of the string being truncated contains the search string...

Function TruncateString$(sText$, sFind$, Optional lStart& = 1)
If InStr(sText, sFind) 0 Then
'Truncate
TruncateString = Mid$(sText, lStart, InStr(sText, sFind) - lStart)
Else
'Return original string
TruncateString = sText
End If
End Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion