Il giorno venerd́ 27 marzo 2015 13:03:47 UTC+1, Robert Crandal ha
scritto:
Suppose I have the following string.
Dim s as String
s = "Always eat lots of fruits and vegetables every day."
I would like to be able to truncate this string as quickly
as possible, beginning from a word of my choosing, all
the way to the end of the string.
So, if I choose the word "and" as my target word, the
above string should be transformed into:
"Always eat lots of fruits "
Essentially, all text after the first occurence of "and"
was removed from the string.
I'm looking for solution that runs quickly. Thanks!
Hi,
Try
Left$(k, InStr(1, k, f, vbTextCompare) - 1)
Given the OP's criteria is "..as quickly as possible,...", the Mid()
function is considerably faster!
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion