Find a String within Text at specific occurance

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
<pre style="font-family:Consolas I managed to do this. But it is tedious <span style="color:blue Dim ss = <span style="color:#a31515 "it is text sample to search in. How to make it in a function? Here is how I think in it. Let find the 3rd it" <span style="color:blue Dim first_it = ss.IndexOf(<span style="color:#a31515 "it") + <span style="font-weight:bold; color:red 1<br/> MsgBox(first_it.ToString)
<span style="color:blue Dim second_it = ss.IndexOf(<span style="color:#a31515 "it",first_it) + <span style="font-weight:bold; color:red 1
MsgBox(second_it.ToString)
<span style="color:blue Dim third_it = ss.IndexOf(<span style="color:#a31515 "it",second_it) + <span style="font-weight:bold; color:red 1
MsgBox(third_it.ToString)

<span style="color:green first it = 1<br/><span style="color:green second it = 45<br/><span style="color:green third it = 86<br/><span style="color:green Forth it = 108<span style="color:green <br/> <span style="font-family:Consolas; font-size:14.44444465637207px; line-height:24.44444465637207px; white-space:pre How I can make a function like Below <span style="font-family:Consolas; font-size:14.44444465637207px; line-height:24.44444465637207px; white-space:pre Function CharAt(ByVal SearchIn as String, ByVal SearchFor as String, ByVal Occurance as Integer) As Integer <span style="font-family:Consolas; font-size:14.44444465637207px; line-height:24.44444465637207px; white-space:pre Where CharAt(ss,"it",3) returns 86 <span style="font-family:Consolas; font-size:14.44444465637207px; line-height:24.44444465637207px; white-space:pre Thanks<br/>





[/code]<hr class="sig Blog: http://samir-ibrahim.blogspot.com/

View the full article
 
Back
Top