Option Explicit
Public Function NbInStr(ByVal MyStart As Long, ByVal MyWord As String, ByVal MyString As String) As Long
If MyStart < 1 Or LenB(MyWord) < 2 Or LenB(MyString) < 2 Then Exit Function
Dim i As Long, MyCounter As Long
MyCounter = 0
For i = MyStart * 2 - 1 To LenB(MyString) Step 2
If MidB(MyString, i, LenB(MyWord)) = MyWord Then MyCounter = MyCounter + 1
Next i
NbInStr = MyCounter
End Function
Sub Exemple_Utilisation()
Debug.Print NbInStr(1, "mot", "Compte le nombre de mot 'mot' dans cette chaine")
' retournera 2
End Sub