Using TextBox as a buffer

  • Thread starter Thread starter bud1chicago
  • Start date Start date
B

bud1chicago

Is there a simple way to use a textbox as a buffer that holds the last
N lines or characters for logging info? Thanks. -- Bud
 
* (e-mail address removed) scripsit:
Is there a simple way to use a textbox as a buffer that holds the last
N lines or characters for logging info?

Yes, if you do buffer management yourself.
 
james said:
Of course you could but why? Why not simply store it in a string ?

JIM

I guess I may not have been clear. I have an application that runs
24x7. Periodically, I need to display a message to the user so I spit
it out to a textbox using the AppendText() method. The textbox
control is limited to 32K bytes of data, so what I'd like to do is
display the last 100 lines or so messages and every time I add a new
line, have the oldest message fall off the screen.

Is there a simple way to do this? I could keep a circular array of
strings in memory and refill the textbox from this array every time I
get a new message to display but I would think this would be very
inefficient and would probably cause a lot of flickering on the
display. There must be a better way that I haven't thought of.
Probably something obvious... -- Bud
 
Is there a simple way to do this? I could keep a circular array of
strings in memory and refill the textbox from this array every time I
get a new message to display but I would think this would be very
inefficient and would probably cause a lot of flickering on the
display. There must be a better way that I haven't thought of.
Probably something obvious... -- Bud

Rather than keeping the strings themselves and repopulating the
textbox, just keep the *lengths* of the strings, and you can work out
how much to chop off the start each time you want to update it.
 
Why not use a listbox instead? It is easier for you to keep track how
many lines have been added. And probably you can avoid the overhead of
manipulating string.
 
Back
Top