Nombre d'occurence d'un caractère dans un chaine

CochonPerdu Messages postés 42 Date d'inscription lundi 6 mai 2002 Statut Membre Dernière intervention 12 août 2003 - 14 mai 2002 à 11:12
cs_Cath Messages postés 27 Date d'inscription samedi 13 avril 2002 Statut Membre Dernière intervention 26 novembre 2005 - 14 mai 2002 à 18:17
Bonjour,
Existe-t-il une fonction pour compter le nombre d'occurences d'un caractère dans une chaine de caractère.
Par ex, combien y a-t-il de tabulation ?

Merci d'avance :)

1 réponse

cs_Cath Messages postés 27 Date d'inscription samedi 13 avril 2002 Statut Membre Dernière intervention 26 novembre 2005
14 mai 2002 à 18:17
Salut,
La fonction Instr te fournira la réponse
Par exemple :
Dim stA as String
Dim Nbr as Integer
Dim PChn as Integer
Dim Trouve as Integer
stA = "Bonjour " & Chr$(9) & "Madame " & Chr$(9) & "Ginette "
PChn = 1 'Début de la recherche
Do
Trouve = Instr(PChn, stA, Chr$(9))
If Trouve > 0 then
Nbr = Nbr + 1
PChn = Trouve +1
Else
Exit Do
End if
Loop

A+
Cath
0
Rejoignez-nous