NickGen
Messages postés17Date d'inscriptionjeudi 9 janvier 2003StatutMembreDernière intervention 7 avril 2004
-
29 janv. 2003 à 12:20
naim1970
Messages postés26Date d'inscriptionmardi 15 juin 2004StatutMembreDernière intervention29 octobre 2008
-
17 oct. 2008 à 21:06
Bonjour, voici mes questions: Comment puis-je copier une ligne de texte a partir d'un textbox multiline et la récupérer dans une variable en sachant que j'ai plusieurs lignes de textes dans le textbox?
Et comment faire ensuite pour passer à une autre ligne, ou revenir en arrière dans un textbox multiline?
Merci d'avance pour vos réponses.
Nick
naim1970
Messages postés26Date d'inscriptionmardi 15 juin 2004StatutMembreDernière intervention29 octobre 2008 17 oct. 2008 à 21:06
Voici deux exemples pour copier les lignes depuis Richtextbox1 vers Textbox1 ;
1)
Copier lignes récursivement depuis Richtextbox1 vers Textbox1
Dim line As String
For Each line In Me.RichTextBox1.Lines
Try
If Me.TextBox1.Text.Length < 1 Then
Me.TextBox1.Text = line
Else
Me.TextBox1.Text = Me.TextBox1.Text & System.Environment.NewLine & line
End If
Catch ex As Exception
MsgBox("Ligne vide !")
End Try
Next
2)
Copier une ligne définie sur "Textbox2" donc depuis Richtextbox1 vers Textbox1
Dim i As Integer
i = System.Convert.ToInt32(TextBox2.Text) - 1
Try
If Me.TextBox1.Text.Length < 1 Then
Me.TextBox1.Text = Me.RichTextBox1.Lines.GetValue(i)
Else
Me.TextBox1.Text = Me.TextBox1.Text & System.Environment.NewLine & Me.RichTextBox1.Lines.GetValue(i)
End If
Catch ex As Exception
MsgBox("Ligne est vide !")
End Try