Travailler avec une chaine...

smashthestate Messages postés 3 Date d'inscription vendredi 24 janvier 2003 Statut Membre Dernière intervention 29 août 2003 - 13 mars 2003 à 04:35
fredlynx Messages postés 662 Date d'inscription mercredi 16 janvier 2002 Statut Modérateur Dernière intervention 16 octobre 2010 - 13 mars 2003 à 08:41
Bonjour,
Je voulais savoir si il est possible de trouver les caracteres compris entre deux symboles comme [ ] ou < > ou { }

Exemple :

allo mon grand [ca va bien] ? jespere que oui

je dois pouvoir travailler seulement avec les caracteres compris entre les [ ]

Merci !!

Heelios !!

1 réponse

fredlynx Messages postés 662 Date d'inscription mercredi 16 janvier 2002 Statut Modérateur Dernière intervention 16 octobre 2010 1
13 mars 2003 à 08:41
[Voili une idée.... br br Private Sub Command1_Click br Dim Position As Long br Dim ReturStr As String br Position = 1 br If MatchStr allo mon grand [ca va bien] ? jespere que oui , [ , Voili une idée.... br br Private Sub Command1_Click br Dim Position As Long br Dim ReturStr As String br Position = 1 br If MatchStr allo mon grand [ca va bien] ? jespere que oui , [ , ]", Position, ReturStr) Then
'Si arrive Ici
'ReturStr => Contient "ca va bien"
'Position => Position de recherche suivante de la chaine
End If
End Sub

Private Function MatchStr(StrChaine As String, CarStart As String, CarStop As String, PosiStart As Long, StrResult As String) As Boolean
Dim PosiDeb As Long
Dim PosiFin As Long
PosiDeb = InStr(PosiStart, StrChaine, CarStart, vbTextCompare)
If PosiDeb = 0 Then Exit Function
PosiFin = InStr(PosiStart + PosiDeb, StrChaine, CarStop, vbTextCompare)
If PosiFin = 0 Then Exit Function
StrResult = Mid(StrChaine, PosiDeb + 1, PosiFin - PosiDeb - 1)
PosiStart = PosiFin + 1
MatchStr = True
End Function

<center>http://www.fredlynx.com
</center>
0