using Instr Function

Count the number of times "is" repeated in the below string

s="This is sample"
p=1
cnt=0
while instr(p,s,"is")>0
   cnt=cnt+1
   p=instr(p,s,"is")+len("is")
wend
msgbox "Is repeated times are  "&cnt
==================================
''''Another logic

s="This is sample"
a=split(s,"is")
msgbox "Is is repated for  "&ubound(a)
====================================
'''Another Logic

s="This is sample"
cnt=0
For i=1 to len(s)
    a=mid(s,i,2)
    If a="is" Then
        cnt=cnt+1
    End If
Next
msgbox "is repeated for  "&cnt























Comments