View Single Post
Old 11-30-2004, 12:16 PM   #8 (permalink)
kebo
Tilted
 
kebo's Avatar
 
Location: reno,nv
a way to count occurences of one string inside of another:

Dim S As String
Dim position As Long
Dim SearchString As String
Dim count As Long

S = " This is a great sentence. It is not very long, but is also quite lame. It is however unimportant and is not very exciting"
SearchString = "is"

count = 0
position = InStr(S, SearchString)
Do Until position = 0
count = count + 1
position = InStr(position + 1, S, SearchString)
Loop
debug.print count
End Sub

its not fully tested but seems to work
kevin
kebo is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73