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
WebMaster-------------------------------
Réponse au message :
-------------------------------
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
lngIndice = InStr(1, txtTexte.Text, " ", vbTextCompare)
If lngIndice <> 0 Then
lngDebut = 1
Do Until lngIndice = 0
lngIndice = InStr(lngDebut, txtTexte.Text, " ", vbTextCompare)
strMot = Mid(txtTexte, lngDebut, lngIndice)
If StrReverse(strMot) = strMot Then
intCompteur = intCompteur + 1
End If
lngDebut = lngIndice + 1
Loop
Else
lngIndice = InStr(1, txtTexte.Text, " ", vbTextCompare)
If lngIndice <> 0 Then
If StrReverse(strMot) = strMot Then
intCompteur = intCompteur + 1
End If
End If
End If
MsgBox intCompteur
End Sub