Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add 28k lines to Rich Text Box 2

Status
Not open for further replies.

ErroR

Technical User
Apr 9, 2001
79
US
I'm trying to use a rich text box for logging, I wrote a small app to automate recovering files from our snapshot backups. In particular, we're using it to repair the over 7000 .jpg files that the LoveLetter worm destoryed (ONE damn computer out of 5000 was missed in the updates)

So, there are at least four lines of logged text for each file. Using the following code:

txtLog.txt = txtLog.Text & vbCrLf & strTextToLog

So that copies the entire contents of the box, lays it down and then adds my line. Problem is, once there are several 10s of thousands of lines, it seems to get slow...

Is there not an AddLine function or something? Is there a better control to be using?
 
Use .SelStart and .SelLength.
'Set .SelStart to end of box
rtf.SelStart = 1999999999 ' set to max - RTF sets to actual
rtf.SelText = newtext
DO NOT do
rtf.SelStart = Len(rtf.Text)
Len gets the length of a string. To get the string, the entire contents of the RTF has to be fetched out into a string.
BTW, these are the same properties that are available for textboxes but people get away with what you did because of the small amount of text.
 
John that worked great, exactly what I needed, thanks a million...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top