Rechercher des mot et les remplacer

Gabriel - 11 mars 2001 à 04:45
cs_birane Messages postés 1 Date d'inscription mercredi 15 février 2006 Statut Membre Dernière intervention 7 mars 2006 - 7 mars 2006 à 18:04
bonjour... si j'ai le texte ci dessous:

Bonjour TOTO salut 12345 tref abc
qwertry salut 244444 klo

Je veux rechercher tous les mot "salut"
et les remplacer par "ALLO"

merci.......

(si possible, remplacer le mot meme si "salut" est "Salut" ou "SALUT" ou "SaLuT" ou ...)

MERCI

2 réponses

Voila un exemple que je viens de faire :

Option Explicit

Private Sub Form_Load()

Text1.Text = "Bonjour TOTO salut 12345" & vbCrLf
Text1.Text = Text1.Text & "tref abc qwertry salut" & vbCrLf
Text1.Text = Text1.Text & "244444 klo" & vbCrLf
Text1.Text = Text1.Text & "VB_MAN te dit SaLuT commen ca va" & vbCrLf
Text1.Text = Text1.Text & "Moi ca va bien sAlUt toi aussi"

End Sub

Private Sub Command1_Click()

Dim lStart As Long
Dim Chaine As String

On Error Resume Next

lStart = 1
Chaine = Text1.Text

Do While lStart > 0

lStart = InStr(lStart, LCase$(Chaine), "salut")

If lStart > 0 Then

Chaine = Mid$(Chaine, 1, lStart - 1) & "ALLO" & Mid$(Chaine, lStart + Len("ALLO") + 1)

End If

DoEvents
Loop

MsgBox "Voila le texte :" & Chr$(13) & Chr$(13) & Chaine, vbInformation, App.Title

End Sub
0
cs_birane Messages postés 1 Date d'inscription mercredi 15 février 2006 Statut Membre Dernière intervention 7 mars 2006
7 mars 2006 à 18:04
j'aurais préferé la recherche qui souligne dans tout le texte le mot rechercher.Et qui donne son nombre d'occurance dans le texte .
MERCI DE VOTRE AIDE
0
Rejoignez-nous