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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upper limit of a textbox? 1

Status
Not open for further replies.

dwu1998

Programmer
Jan 17, 2001
22
US
Hi all,
In an application, I have a textbox to show selective contents of a file. However, when the content gets bigger, I get an "Out of Memory" error. Does anybody know if there is a limit on the size of text that can be shown in a textbox? Any fixes?
Many thanks in advance.
 
How long is the text in the textbox when you get the out of memroy error? - Jeff Marler B-)
 
Hi Jeff,
The file is about 85k. I played with it in vb6 and found out whenever the text was over 63k I got the error.

Thanks,
 
I could get 61000 carakters into the text control, whith the command len(filenumber) you get the length of the file.
If it is over 61000 you should not try to put it in a text box control.

If you want to read textfiles larger than 61000 you should check the size, scale a scroll bar, read the file binary and jump to somewere in the file if the scrollbar is moved by reading the file at another starting point, you can do this with the following command:
dim sometext As String * 1000 ' sometext is 1000 carakters long
dim beginread as ling ' beginread is at what carakter you begin reading the file.
Open "c:\myfile" For Binary Access Read Lock Read As #1
Get #1, beginread, sometext

Hope this wil help you a bit, could not get the exact lengt wich will fit into a text box only got the documentation on vb2 wich is 32k.
 
I got conflicting figures on that issue:

Official Microsoft documentation (VB6 Language Reference p. 1036) puts a limit of either 2 or 32K.

... The Text setting for a [Textbox[/b] control is limited to 2,048 characters unless the MultiLine property is True, in which case the limit is about 32K.

Other sources (e.g. Mastering VB6 by Petroutsos, SYBEX, p 230) put a limit of approximately 64K on the Multiline Textbox (255 characters on single line Textbox), which seems to correspond to your experience.

The length can be further limited by the MaxLength property.

If you hit the wall:
1. check the MaxLength property
2. if zero or not specified, check MultiLine
3. if this fails, switch to the Rich TextBox Control, which does not suffer from these limitations. _________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
32k is correct but I think this is an old "d group" throw back, I know back in the 16 bit days you could fit 2 ascii chr$ into one byte so 32k x 2 seems like 64k in chr$?
 
Very interesting! I just ran into the same problem with the Textbox size limit. Is RichTextBox Control part of the default VB installation or it's some third-party control? Where could I get it?

regards,
rydel n23
 

Right click on toolbox and select components and scroll down until you see Microsoft Rich Textbox control. Select it and click OK.

Good Luck

 
Thank you, vb5prgrmr! Duh, that was a dumb question, I found the control 10 minutes after posting the question... Stupid me...

For all others that are interested in this control:

---

The RichTextBox is a additional VB component that comes with Visual Basic Professional and Enterprise Edition. This control allows your program to create formatted text (i.e. bulleted, bold and coloured text) in RTF (Rich Text Format). This file format can then be read by other programs like WordPad and MS Word.

If you will be installing a program using the RichTextBox control, you need to distribute the following files:
RichTx32.ocx - 200KB
RichEd32.dll - 171KB


---

Though I didn't find any info on the size limitation. I've tried the files that I needed (100-500KB) and they all worked fine, but I didn't really test the upper limit of the size. If anyone knows, just post it here.




regards,
rydel n23
 
Hello all,

I found this email thread interesting in that I too need to do some text manipulation with RTF documents. I need to find a special label in teh document and capture the next 30 characters after that. Basically I need to extract teh last name found in the document.

Got to the point of reading in the file using the FileSystemObject method and pasting the contents into a RichTextBox control. Then I had hoped to do INSTR commands trying to find the characters I need. But I think that is too much hassle. I tried looking at RTF to ASCII text file converters but can't find one that I can use in my VB 6 code.

Anybody got any other nifty ideas for retrieving a piece of text from an RTF file document? (PS. The document was actually created as an RTF export file destination from a Crystal Reports 8 process.)

Thanks in advance.

 

gregoriw,

You can load up the RTF file into the RTB and then use the text methods of the RTB...
[tt]
StringVariable = RTB.Text 'instead of RTB.TextRTF which is RTF format
[/tt]

Good Luck

 
I put two TextBoxes on a form - One with Multiline set to True, the other with Multiline set to False - Added a routine to append 1024 "A"s at a time to one or the other textbox.

For the Multiline textbox I found that after 33 iterations I got error Out of memory with a length of 33792 and was very slow, but with the non-multiline textbox the length stayed at 32766, with no error and raced along.

My two cents.


Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top