Discussion:
Rich Text Box vs List Box
(too old to reply)
Les
2003-11-02 07:01:53 UTC
Permalink
I have 15,000 rows of data which currently I have been sending to a list
box. I seem to remember someone here stating that it is either faster to
load a list box or faster to load a rich text box. Can someone tell me
which is the more efficient way? And can you tell me what is the quickest
way of sending these rows to a rich text box? I also rememeber trying to do
this a while ago by concatenating a string variable and when finished sent
it to the rich text box but this appeared to tak a long time to do! What is
the most efficient way of loading 15,000 rows of data into a rich text box?

Thanks in advance
Rick Rothstein
2003-11-02 09:32:26 UTC
Permalink
Post by Les
I have 15,000 rows of data which currently I have been sending to a list
box. I seem to remember someone here stating that it is either faster to
load a list box or faster to load a rich text box. Can someone tell me
which is the more efficient way? And can you tell me what is the quickest
way of sending these rows to a rich text box? I also rememeber trying to do
this a while ago by concatenating a string variable and when finished sent
it to the rich text box but this appeared to tak a long time to do! What is
the most efficient way of loading 15,000 rows of data into a rich text box?
If your data is in a text file (either plain or rich text format), the
RichTextBox has a LoadFile method, which allows you to specify which type of
file will be loaded, and a FileName property, which figures out the file
type automatically. You can use either one to load the file and it will do
so very, very quickly.

Rick - MVP
Les
2003-11-02 17:10:10 UTC
Permalink
Hi Rick,

I am generating all 15,000 rows and wanted to know which is faster to load ?
a rich text box or a list box and what is the fastest way (ie
text1.txt=text1.txt & .........txt stuff) of loading it.

Thanks,

Les
Post by Rick Rothstein
Post by Les
I have 15,000 rows of data which currently I have been sending to a list
box. I seem to remember someone here stating that it is either faster to
load a list box or faster to load a rich text box. Can someone tell me
which is the more efficient way? And can you tell me what is the quickest
way of sending these rows to a rich text box? I also rememeber trying
to
Post by Rick Rothstein
do
Post by Les
this a while ago by concatenating a string variable and when finished sent
it to the rich text box but this appeared to tak a long time to do!
What
Post by Rick Rothstein
is
Post by Les
the most efficient way of loading 15,000 rows of data into a rich text
box?
If your data is in a text file (either plain or rich text format), the
RichTextBox has a LoadFile method, which allows you to specify which type of
file will be loaded, and a FileName property, which figures out the file
type automatically. You can use either one to load the file and it will do
so very, very quickly.
Rick - MVP
Veign
2003-11-02 17:23:02 UTC
Permalink
I know this may be a simple solution, but instead of waiting for an answer
why not just try and see..

Also, whats the point of loading all 15,000 rows?..No person could possibly
look through all rows and make something of the data...Could you do
something different to the algorithm to load less rows of data?

If you want post what you are trying to accomplish with loading all 15,000
rows and maybe we can assist in some alternate methods..
--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
Application Design Section
http://www.veign.com/information/application/info_app.html
------
Post by Les
Hi Rick,
I am generating all 15,000 rows and wanted to know which is faster to load ?
a rich text box or a list box and what is the fastest way (ie
text1.txt=text1.txt & .........txt stuff) of loading it.
Thanks,
Les
Post by Rick Rothstein
Post by Les
I have 15,000 rows of data which currently I have been sending to a list
box. I seem to remember someone here stating that it is either faster
to
Post by Rick Rothstein
Post by Les
load a list box or faster to load a rich text box. Can someone tell me
which is the more efficient way? And can you tell me what is the
quickest
Post by Rick Rothstein
Post by Les
way of sending these rows to a rich text box? I also rememeber trying
to
Post by Rick Rothstein
do
Post by Les
this a while ago by concatenating a string variable and when finished
sent
Post by Rick Rothstein
Post by Les
it to the rich text box but this appeared to tak a long time to do!
What
Post by Rick Rothstein
is
Post by Les
the most efficient way of loading 15,000 rows of data into a rich text
box?
If your data is in a text file (either plain or rich text format), the
RichTextBox has a LoadFile method, which allows you to specify which
type
Post by Les
of
Post by Rick Rothstein
file will be loaded, and a FileName property, which figures out the file
type automatically. You can use either one to load the file and it will do
so very, very quickly.
Rick - MVP
Les
2003-11-03 03:43:27 UTC
Permalink
Hi Veign,

First I did make a mistake in my post saying Text1.text since my question in
fact had to do with comapring a rich text box to a list text box. Sorry
Rick for the misleading info. Anyway the reason for the 15,000 rows
(potentially) I will try to explain. This application wil be doing a bunch
of comparisons of 7 or 8 accounting tables each of which will contain
information relevant to each other. The customer requires that all rows
that meet a fixed bunch of criteria be displayed since he will then need to
do further comparisons of the records that are outputed in either this list
box or rich text box. Although it is unlikely that the list will contain
15,000 rows I have been told it will not exceed this limit. My interest in
the rich text box is that this object has the extra property of a horizontal
scroll bar which might be required if the 9 columns of data I have been
asked to display exceeds the width of there monitor. I remember someone
here some time ago mentioned he/she experienced a limit as to how many
entries were allowed to be added to the list box where as I know that a rich
text box is limited to storage space ( I beleive). I am merely trying to
cover my options and doing things right.

Sorry for the confusion guys, my apologies,

Les
Post by Veign
I know this may be a simple solution, but instead of waiting for an answer
why not just try and see..
Also, whats the point of loading all 15,000 rows?..No person could possibly
look through all rows and make something of the data...Could you do
something different to the algorithm to load less rows of data?
If you want post what you are trying to accomplish with loading all 15,000
rows and maybe we can assist in some alternate methods..
--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
Application Design Section
http://www.veign.com/information/application/info_app.html
------
Post by Les
Hi Rick,
I am generating all 15,000 rows and wanted to know which is faster to
load
Post by Veign
?
Post by Les
a rich text box or a list box and what is the fastest way (ie
text1.txt=text1.txt & .........txt stuff) of loading it.
Thanks,
Les
Post by Rick Rothstein
Post by Les
I have 15,000 rows of data which currently I have been sending to a
list
Post by Les
Post by Rick Rothstein
Post by Les
box. I seem to remember someone here stating that it is either faster
to
Post by Rick Rothstein
Post by Les
load a list box or faster to load a rich text box. Can someone tell
me
Post by Les
Post by Rick Rothstein
Post by Les
which is the more efficient way? And can you tell me what is the
quickest
Post by Rick Rothstein
Post by Les
way of sending these rows to a rich text box? I also rememeber trying
to
Post by Rick Rothstein
do
Post by Les
this a while ago by concatenating a string variable and when finished
sent
Post by Rick Rothstein
Post by Les
it to the rich text box but this appeared to tak a long time to do!
What
Post by Rick Rothstein
is
Post by Les
the most efficient way of loading 15,000 rows of data into a rich text
box?
If your data is in a text file (either plain or rich text format), the
RichTextBox has a LoadFile method, which allows you to specify which
type
Post by Les
of
Post by Rick Rothstein
file will be loaded, and a FileName property, which figures out the file
type automatically. You can use either one to load the file and it
will
Post by Veign
do
Post by Les
Post by Rick Rothstein
so very, very quickly.
Rick - MVP
Rick Rothstein
2003-11-04 16:46:59 UTC
Permalink
Since you have several columns of information and want to display them (and
possibly do some kind of additional comparisons with them), maybe a Grid
control would meet your needs.

Rick - MVP
Post by Les
Hi Veign,
First I did make a mistake in my post saying Text1.text since my question in
fact had to do with comapring a rich text box to a list text box. Sorry
Rick for the misleading info. Anyway the reason for the 15,000 rows
(potentially) I will try to explain. This application wil be doing a bunch
of comparisons of 7 or 8 accounting tables each of which will contain
information relevant to each other. The customer requires that all rows
that meet a fixed bunch of criteria be displayed since he will then need to
do further comparisons of the records that are outputed in either this list
box or rich text box. Although it is unlikely that the list will contain
15,000 rows I have been told it will not exceed this limit. My interest in
the rich text box is that this object has the extra property of a horizontal
scroll bar which might be required if the 9 columns of data I have been
asked to display exceeds the width of there monitor. I remember someone
here some time ago mentioned he/she experienced a limit as to how many
entries were allowed to be added to the list box where as I know that a rich
text box is limited to storage space ( I beleive). I am merely trying to
cover my options and doing things right.
Sorry for the confusion guys, my apologies,
Les
Post by Veign
I know this may be a simple solution, but instead of waiting for an answer
why not just try and see..
Also, whats the point of loading all 15,000 rows?..No person could
possibly
Post by Veign
look through all rows and make something of the data...Could you do
something different to the algorithm to load less rows of data?
If you want post what you are trying to accomplish with loading all 15,000
rows and maybe we can assist in some alternate methods..
--
Chris Hanscom
MVP (Visual Basic)
http://www.veign.com
Application Design Section
http://www.veign.com/information/application/info_app.html
------
Post by Les
Hi Rick,
I am generating all 15,000 rows and wanted to know which is faster to
load
Post by Veign
?
Post by Les
a rich text box or a list box and what is the fastest way (ie
text1.txt=text1.txt & .........txt stuff) of loading it.
Thanks,
Les
Post by Rick Rothstein
Post by Les
I have 15,000 rows of data which currently I have been sending to a
list
Post by Les
Post by Rick Rothstein
Post by Les
box. I seem to remember someone here stating that it is either
faster
Post by Veign
Post by Les
to
Post by Rick Rothstein
Post by Les
load a list box or faster to load a rich text box. Can someone tell
me
Post by Les
Post by Rick Rothstein
Post by Les
which is the more efficient way? And can you tell me what is the
quickest
Post by Rick Rothstein
Post by Les
way of sending these rows to a rich text box? I also rememeber
trying
Post by Veign
Post by Les
to
Post by Rick Rothstein
do
Post by Les
this a while ago by concatenating a string variable and when
finished
Post by Veign
Post by Les
sent
Post by Rick Rothstein
Post by Les
it to the rich text box but this appeared to tak a long time to do!
What
Post by Rick Rothstein
is
Post by Les
the most efficient way of loading 15,000 rows of data into a rich
text
Post by Veign
Post by Les
Post by Rick Rothstein
box?
If your data is in a text file (either plain or rich text format), the
RichTextBox has a LoadFile method, which allows you to specify which
type
Post by Les
of
Post by Rick Rothstein
file will be loaded, and a FileName property, which figures out the
file
Post by Veign
Post by Les
Post by Rick Rothstein
type automatically. You can use either one to load the file and it
will
Post by Veign
do
Post by Les
Post by Rick Rothstein
so very, very quickly.
Rick - MVP
Rick Rothstein
2003-11-02 17:42:20 UTC
Permalink
You are going to have to be a little more careful with your typing... you
say RichTextBox in your Subject line, but your example says text1.txt...
text1 would seem to indicate a TextBox (not RichTextBox), but the .txt is
not a property of a TextBox (that would be .Text)... actually, .txt would be
the extension of a text file (which I asked if you were using; although I'm
assuming when you say that you are "generating all 15,000 rows", that means
your doing so "in code").

Anyway, if you are generating the 15,000 row of data in code, I'd use the
SelText property to add the text to either the TextBox or RichTextBox as its
much faster than concatenating text onto the Text property or either... much
faster.

For N = 1 To 15000
Text1.SelTex = AssumedArrayOfData(N) & vbNewLine
Next

I'd assuming adding text this way to a TextBox would be faster than doing so
to a RichTextBox (I'm guessing there is less overhead in a TextBox).
However, I don't know which would be faster between a TextBox or a ListBox,
but you should be able to test that easily enough using your own live data.

Rick - MVP
Post by Les
Hi Rick,
I am generating all 15,000 rows and wanted to know which is faster to load ?
a rich text box or a list box and what is the fastest way (ie
text1.txt=text1.txt & .........txt stuff) of loading it.
Thanks,
Les
Post by Rick Rothstein
Post by Les
I have 15,000 rows of data which currently I have been sending to a list
box. I seem to remember someone here stating that it is either faster
to
Post by Rick Rothstein
Post by Les
load a list box or faster to load a rich text box. Can someone tell me
which is the more efficient way? And can you tell me what is the
quickest
Post by Rick Rothstein
Post by Les
way of sending these rows to a rich text box? I also rememeber trying
to
Post by Rick Rothstein
do
Post by Les
this a while ago by concatenating a string variable and when finished
sent
Post by Rick Rothstein
Post by Les
it to the rich text box but this appeared to tak a long time to do!
What
Post by Rick Rothstein
is
Post by Les
the most efficient way of loading 15,000 rows of data into a rich text
box?
If your data is in a text file (either plain or rich text format), the
RichTextBox has a LoadFile method, which allows you to specify which
type
Post by Les
of
Post by Rick Rothstein
file will be loaded, and a FileName property, which figures out the file
type automatically. You can use either one to load the file and it will do
so very, very quickly.
Rick - MVP
Ben Taylor
2003-11-03 10:41:42 UTC
Permalink
There's no comparing a listbox to an rtb - the'yre totally
different beasts with totally different purposes. It's
like comparing an apple to a ... donkey.
-----Original Message-----
I have 15,000 rows of data which currently I have been
sending to a list
box. I seem to remember someone here stating that it is
either faster to
load a list box or faster to load a rich text box. Can
someone tell me
which is the more efficient way? And can you tell me
what is the quickest
way of sending these rows to a rich text box? I also
rememeber trying to do
this a while ago by concatenating a string variable and
when finished sent
it to the rich text box but this appeared to tak a long
time to do! What is
the most efficient way of loading 15,000 rows of data
into a rich text box?
Thanks in advance
.
Ben Taylor
2003-11-03 10:43:34 UTC
Permalink
You could set off a different thread to read from the
database, as this will be consuming the server's resources
not the clients. There's a way of subclassing a listbox in
order to post messages to it - the data reading thread can
then have posted the next call to the server for the next
record while the listbox's updating itself. Just an idea.
-----Original Message-----
I have 15,000 rows of data which currently I have been
sending to a list
box. I seem to remember someone here stating that it is
either faster to
load a list box or faster to load a rich text box. Can
someone tell me
which is the more efficient way? And can you tell me
what is the quickest
way of sending these rows to a rich text box? I also
rememeber trying to do
this a while ago by concatenating a string variable and
when finished sent
it to the rich text box but this appeared to tak a long
time to do! What is
the most efficient way of loading 15,000 rows of data
into a rich text box?
Thanks in advance
.
Woody
2003-11-03 12:31:59 UTC
Permalink
i use text box for standard single or multiline character data, rich
text of there is need of being able to cut/copy/paste contents in or
out, listbox where i have repetitive data.

all are different critters and usually work best when used for their
purposes.

Woody
any sugestion or comment made by me should be examined first for
validity and appropriateness before assuming i have any idea at all
what the heck i am talking about. I am not responsible for anything you
may see with my name attached to it, i think.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jeff Bennett
2003-11-03 16:24:09 UTC
Permalink
Post by Les
I have 15,000 rows of data which currently I have been sending to a list
box. I seem to remember someone here stating that it is either faster to
load a list box or faster to load a rich text box. Can someone tell me
which is the more efficient way? And can you tell me what is the quickest
way of sending these rows to a rich text box? I also rememeber trying to do
this a while ago by concatenating a string variable and when finished sent
it to the rich text box but this appeared to tak a long time to do! What is
the most efficient way of loading 15,000 rows of data into a rich text box?
Thanks in advance
1) Unless you need the formatting of a RichTextbox I would
suggest comparing plain textbox to listbox rather than RichTextbox
to listbox. I'm very confident Textbox will be faster than RichTextbox.
That said I'm also sure that the Listbox will be faster than the textbox

2) The fastest way to load into either RichTextbox or plain
text box would be to combine all your 15000 rows into a
single string.

For example
For i = 1 to 15000
aString = aString & "this is line " & i & vbCrLf
next
RichTextBox1.Text = aString
' or Textbox1.Text = aString

This will be much faster than building up the RichTextbox ( or textbox )
content line by line. If you do need to use the textbox approach line
by line use the SelText property

For i = 1 to 15000
With RichTextbox1 ' or Textbox1
.SelText = "this is line " & i & vbCrLf
.SelStart = Len ( .Text)
next

3) Ok, all that aside - consider it just for theoretical purposes
The Listbox will be faster.

For i = 1 to 15000
List1.AddItem "this is line " & i
next

Is much faster than any of the above approaches.

4) Aside from speed the big advantage to a Listbox type control
would be in terms of list management - ability to select
a single row, move/delete a row, insert a row in a specific
position, etc

5) If the reason you are looking at RichTextbox is that
you are really needing to show formatted text
( mixed bold, italic, colors, etc) then let me know.
In this case I might suggest another control
( our own TList control - a kind of List / Tree / Grid
control with support for Rich Text formatting.

-----

* * Please include a copy of this note with your reply

Jeff Bennett
***@Bennet-Tec.Com

Bennet-Tec Information Systems, Inc
50 Jericho Tpk, Jericho, NY 11753
Phone 516 997 5596, Fax - 5597
WWW.Bennet-Tec.Com

RELIABLE Component Software
and Software Development Services
* TList/Pro * ALLText HT/Pro * MetaDraw *

====================== ======================
Les
2003-11-03 17:02:05 UTC
Permalink
Post by Jeff Bennett
Post by Les
I have 15,000 rows of data which currently I have been sending to a list
box. I seem to remember someone here stating that it is either faster to
load a list box or faster to load a rich text box. Can someone tell me
which is the more efficient way? And can you tell me what is the quickest
way of sending these rows to a rich text box? I also rememeber trying to do
this a while ago by concatenating a string variable and when finished sent
it to the rich text box but this appeared to tak a long time to do!
What is
Post by Jeff Bennett
Post by Les
the most efficient way of loading 15,000 rows of data into a rich text box?
Thanks in advance
1) Unless you need the formatting of a RichTextbox I would
suggest comparing plain textbox to listbox rather than RichTextbox
to listbox. I'm very confident Textbox will be faster than RichTextbox.
That said I'm also sure that the Listbox will be faster than the textbox
2) The fastest way to load into either RichTextbox or plain
text box would be to combine all your 15000 rows into a
single string.
For example
For i = 1 to 15000
aString = aString & "this is line " & i & vbCrLf
next
RichTextBox1.Text = aString
' or Textbox1.Text = aString
This will be much faster than building up the RichTextbox ( or textbox )
content line by line. If you do need to use the textbox approach line
by line use the SelText property
For i = 1 to 15000
With RichTextbox1 ' or Textbox1
.SelText = "this is line " & i & vbCrLf
.SelStart = Len ( .Text)
next
3) Ok, all that aside - consider it just for theoretical purposes
The Listbox will be faster.
For i = 1 to 15000
List1.AddItem "this is line " & i
next
Is much faster than any of the above approaches.
4) Aside from speed the big advantage to a Listbox type control
would be in terms of list management - ability to select
a single row, move/delete a row, insert a row in a specific
position, etc
5) If the reason you are looking at RichTextbox is that
you are really needing to show formatted text
( mixed bold, italic, colors, etc) then let me know.
In this case I might suggest another control
( our own TList control - a kind of List / Tree / Grid
control with support for Rich Text formatting.
-----
Hello Jeff and thanks for your clear explanation. Since my last post I
tried comparing speed of rich text box to list and found that your statement
of listbox being much quicker then filling the rich text box is definitly
true. The first reason I was considering a rich text box was I "may" need
the horizontal scrolling capability that a list box does not easily offer me
and second I seem to remember a text box had less storage capability then a
rich text box although I could be mistaken. If not then the text box would
be the preferred candidate vs rich text box. As far as your suggestion to
use a string variable to build all the rows isn't there a limitation for a
large a string this variable can hold? I also ran one other quick test and
found it was actaully quicker to dump the 15,000 rows into a flat file first
then to send the entire contents to a text box! What are your thoughts
there. It took 17 sec to dump all of them to a flat file vs 20 seconds to
send them to a list box. Anyway if my customer has a monitor that will
support the width of the list box I need to use then I will stay with the
list box else I will consider using a text box.

Thanks once again Jeff for your professional help.

Les
Post by Jeff Bennett
* * Please include a copy of this note with your reply
Jeff Bennett
Bennet-Tec Information Systems, Inc
50 Jericho Tpk, Jericho, NY 11753
Phone 516 997 5596, Fax - 5597
WWW.Bennet-Tec.Com
RELIABLE Component Software
and Software Development Services
* TList/Pro * ALLText HT/Pro * MetaDraw *
====================== ======================
Continue reading on narkive:
Loading...