La fonction n'est pas parfaite, je dois l'avouer.
Aussi, j'étais persuadé qu'une autre fonction de VB6 remplit le mandat, mais je n'ai pas trouvé (je me mêle p-ê avec le PHP :)
Public Function strCount(ByVal InChaine As String, ByVal InSousChaine As String, Optional RespecterCasse As VbCompareMethod = vbBinaryCompare) As Integer
'
' Fait le décompte du nombre d'occurences de InSousChaine
' dans InChaine
'
' Retour:
' -2 Si InSousChaine est vide
' -1 Si InChaine est vide
' 0+ Le nombre d'instances trouvées
'
Dim iPos As Integer
Dim iPosPrec As Integer
Dim iLngSC As Integer
Dim iLngChaine As Integer
iPosPrec = 1
strCount = 0
iLngChaine = LenB(InChaine)
If (iLngChaine = 0) Then
strCount = -1
Exit Function
'Else
End If
iLngSC = LenB(InSousChaine)
If (iLngSC = 0) Then
strCount = -2
Exit Function
'Else
End If
Do
iPos = InStr(iPosPrec, InChaine, InSousChaine, RespecterCasse)
If (iPos > 0) Then
strCount = strCount + 1
iPosPrec = iPos + iLngSC + 1 If (iPosPrec >iLngChaine) Then iPos 0
'Else
End If
Loop Until (iPos <= 0)
End Function