|
-
Jul 29th, 2009, 05:08 AM
#1
Thread Starter
Lively Member
Overwrite line in RichTextBox
I'm writing to a RichTextBox using the with command:
Code:
With RichTextBox
.AppendText("blablabla" & vbCrLf)
.ScrollToCaret()
End With
But sometimes I would like to overwrite what I've just written instead of writing it on the next line. Is there a way to do this?
-
Jul 29th, 2009, 05:16 AM
#2
Re: Overwrite line in RichTextBox
you can rotate on each line like:
Code:
for each rt in richtextbox1.lines
if rt.text = 'bla bla' then
rt.text = 'bla bla bla'
end if
next
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 05:20 AM
#3
Thread Starter
Lively Member
Re: Overwrite line in RichTextBox
Isn't there a way to only acces the last line (since this is the one I wanna change). So I can avoid the for loop?
-
Jul 29th, 2009, 05:33 AM
#4
Re: Overwrite line in RichTextBox
i just tried my example and it didn't work, so igonre it.
i'll play with it and get back to you if i'll find a solution
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jul 29th, 2009, 06:00 AM
#5
Re: Overwrite line in RichTextBox
You do need to use the Lines property but it's value is not live, i.e. making changes to it doesn't change the contents of the control. You need to change the array and then assign it back to the property:
vb.net Code:
Dim lines As String() = myRichTextBox.Lines lines(lines.Length - 1) = "This line will replace the last line in the RTB" myRichTextBox.Lines = lines
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|