1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Function Recherche(strIn,strFind)
Mot = ""
intPos = InStr(strIn, strFind) 'Dans ce cas précis, strFind représente le caractère $
newPos = intPos + 1
If intPos > 0 Then
Do
newPos = newPos - 1 ' On parcourt la chaîne en sens inverse à partir du caractère $ jusqu'à trouver un espace
Mot = Mid(strIn, newPos, 1) & Mot
Loop Until Mid(strIn,newPos,1) = " "
newPos = intPos
Do
newPos = newPos + 1 ' On parcourt la chaîne en sens direct à partir du caractère suivant le $ jusqu'à trouver un espace
Mot = Mot & Mid(strIn, newPos, 1)
Loop Until Mid(strIn,newPos,1) = " "
End If
Recherche = Mot
End Function
MsgBox Recherche("Je cherche le mot contenant le car$actère DOLLAR", "$") |