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 39
| Option Explicit
Private Sub UserForm_Initialize()
Dim i As Integer, texto As String
For i = 1 To 100
If i = 1 Then texto = Chr(1) & "Ici nous allons faire de grandes lignes de texte Valeur de liste 1" Else texto = texto & Chr(10) & Chr(1) & "Ici nous allons faire de grandes lignes de texte Valeur de liste " & i
Next i
With TextBox1
.BackStyle = fmBackStyleTransparent
.MultiLine = True
.ScrollBars = fmScrollBarsVertical
.Move 5, 5, Me.Width - 16, Me.Height - 40
.Text = texto & Chr(1)
.SetFocus
.CurLine = 0
End With
End Sub
Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim debSel As Long, finSel As Long, texto As String, txtSel As String, i As Integer
texto = Replace(TextBox1.Text, Chr(10), "")
debSel = TextBox1.SelStart
finSel = TextBox1.SelStart
Do While Mid(texto, debSel, 1) <> Chr(1)
debSel = debSel - 1
Loop
If Mid(texto, finSel, 1) = Chr(1) Then finSel = finSel + 1
Do While Mid(texto, finSel, 1) <> Chr(1)
finSel = finSel + 1
Loop
For i = debSel + 1 To finSel - 1
txtSel = txtSel & Mid(texto, i, 1)
Next i
TextBox1.SelStart = debSel
TextBox1.SelLength = finSel - debSel - 1
Sheets("Feuil1").Range("A1") = Trim(txtSel)
End Sub |
Partager