1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Private Sub Form_Initialize()
comptecar Text1.Text, vbCrLf, nblignes1
comptecar Text1.Text, vbCrLf, nblignes2
If nblignes1 >= nblignes2 Then
VScroll1.Max = nblignes1
Else
VScroll1.Max = nblignes2
End If
End Sub
Private Sub VScroll1_Change()
Text1.SelStart = 0
pos1 = 0
Text2.SelStart = 0
pos2 = 0
For i = pos1 To VScroll1.Value
pos1 = pos1 + InStr(pos1 + 1, Text1.Text, vbCrLf)
Next
For i = 0 To VScroll1.Value
pos2 = pos2 + InStr(pos2 + 1, Text1.Text, vbCrLf)
Next
Text1.SelStart = pos1
Text2.SelStart = pos2
End Sub
Private Sub VScroll1_Scroll()
VScroll1_Change
End Sub
Public Sub comptecar(chaine, car, nbcar)
nbcar = 0: chaine1 = chaine: pos = InStr(chaine1, car)
While pos > 0
nbcar = nbcar + 1
chaine1 = Mid(chaine1, pos + 1)
pos = InStr(chaine1, car)
Wend
End Sub |
Partager