poscur = Text1.SelStart 'trouver la position des deux crochets pos1 = InStrRev(Text1.Text, "[", poscur)
poscur = Text1.SelStart 'trouver la position des deux crochets pos1 = InStrRev(Text1.Text, "[", poscur) pos2 = InStr(pos1, Text1.Text, "]") 'trouver la position du curseur dans le texte If pos1 < pos2 Then 's'assurer que le premier crochet et avant le deuxième ;-) If pos1 <= poscur Then If poscur <= pos2 Then 'Sélectionner la partie entre les crochets (y compris les crochets) Text1.SelStart = pos1 - 1 Text1.SelLength = pos2 - pos1 + 1 Else 'sinon mettre le curseur à sa position 'Text1.SelStart = poscur End If End If End If
Dim Str, StrA, StrB, Result As String Str = "abcd<tefgh>ijlmn" Dim Tableau() As String StrA = "<" StrB = ">" Result = Split(Split(Str, StrA, 2)(1), StrB)(0) MsgBox Result
toto = "salut [balise1], text texte text [balise2]blabla[balise3]atchoum [balise4] a tes souhaits" titi = toto pos1 = InStr(titi, "[") pos2 = InStr(titi, "]") Do While pos1 And pos2 MsgBox Mid(titi, pos1, pos2 - pos1 + 1) titi = Mid(titi, pos2 + 1) pos1 = InStr(titi, "[") pos2 = InStr(titi, "]") Loop
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question