I don't know, I don't have the toolkit. I'd suggest almost the same code and saw yyour reply with code:)
Cetin
>
>That'd return 4 where VFP occurs() would return 2. IOW the one in the toolkit continues search from found+1, not found+searchStrlen.>
>Good catch Cetin ... looks like a bug in this VFP Toolkit method. I've never used it or tested it, so I just posted "as is" from the Toolkit Help. I only have an original version of the Toolkit ... I wonder if there's been bug-fixes or upgrades?
>
>~~Bonnie
>
>
>
>
>>>>You're "creating" strings inside your loop with this statement:
>>>>
>>>> lcString = Mid(lcString, lnLocation + 2)
>>>>
>>>>This is where you would benefit from using StringBuilder.
>>>>
>>>>The example from the VFP Toolkit for .NET doesn't need StringBuilder because it doesn't do this.
>>>
>>>The first example loops thru all characters. So, if I am passing a 17k string, for example, that would mean it would process in the loop 17000 times. I like the second example as it uses a position to start on the next occurence. I will adjust for that one. I use StringBuilder on a lot of places. It is just that this one hasn't been optimized yet. I will do that now. Thanks
>>
>>Michel,
>>However be warned that function unlike its name suggests (and from VFP toolkit) is not one to one match VFP's occurs() behavior. It's arguable which one is correct (probably answer is depends). ie:
>>input string: aaaaa
>>search: aa
>>That'd return 4 where VFP occurs() would return 2. IOW the one in the toolkit continues search from found+1, not found+searchStrlen.
>>Cetin