Besoin d'aide pour un compteur de Polindrome dans une chaine de caractère
cs_Ghis
Messages postés8Date d'inscriptionsamedi 11 mai 2002StatutMembreDernière intervention 7 juin 2002
-
14 mai 2002 à 01:21
fredlynx
Messages postés662Date d'inscriptionmercredi 16 janvier 2002StatutModérateurDernière intervention16 octobre 2010
-
14 mai 2002 à 08:09
Voici mon code pour l'instant. J'ai un bug et n'arrive pas a la trouver. :/
P.S: Un Palindrome, c'est un mot qui s'écrit parreil des deux côté. Ex: ALLA ou BOB
Option Explicit
Private Sub cmdRechercher_Click()
Dim intCompteur As Integer
Dim lngIndice As Long
Dim strMot As String
Dim lngDebut As Long
fredlynx
Messages postés662Date d'inscriptionmercredi 16 janvier 2002StatutModérateurDernière intervention16 octobre 20103 14 mai 2002 à 08:09
ca ça devrait marcher ... enfin si ta fonction reverse fonctionne ... A toi d'analyser ;)
Option Explicit
Private Sub cmdRechercher_Click()
Dim intCompteur As Integer
Dim lngIndice As Long
Dim strMot As String
Dim lngDebut As Long
Dim StrTemp As String
StrTemp = Trim(txtTexte.Text)
If InStr(StrTemp, " ") <> 0 Then
lngDebut = 1
Do
lngIndice = InStr(lngDebut, StrTemp, " ")
If lngIndice = 0 Then Exit Do
strMot = Trim(Mid(txtTexte, lngDebut, lngIndice - 1))
If StrReverse(strMot) = strMot Then
intCompteur = intCompteur + 1
End If
lngDebut = lngIndice + 1
Loop
Else
If Len(StrTemp) > 0 Then
If StrReverse(StrTemp) = StrTemp Then
intCompteur = intCompteur + 1
End If
End If
End If
MsgBox intCompteur
End Sub