Hi,
As I understand, the TextBox control has a limit of 64K characters. Can I somehow increase it throght an API or something?
Thanks
Printable View
Hi,
As I understand, the TextBox control has a limit of 64K characters. Can I somehow increase it throght an API or something?
Thanks
No you can't increase it through an API or something :)
If you "could" increase it through an API then it would have been built like that.
The 64k limit is because the control itself only allows for the allocation of 64k of data space to store its contents.
If you want one bigger you would have to write your own control that managed to control the ability to "page" through data, join and unjoin etc.
Either have something like:
If you don't want that, than I suggest you use a RichTextBox.Code:Private Sub Text1_Change()
On Error Goto ClearText
ClearChat:
Msgbox "Textbox has exceed the limit of characters! Text must be cleared!", vbCritical
Text1.text = ""
End Sub
Try using a Rich text box instead. It should be able to hold more than 64K characters, seeming that wordpad can open very large documents(Wordpad uses RTF boxes).
The rtf box can allocate up to about 2gb of memory.
should be enough for most people
Thanks Paul, Warmaster & Matthew
Is RichTextBox and an RTF box the same thing? Are you saying that RichTextBox has a limit of 2GB? If not, where can I get a hold on RTF box?
Thanks again.
RTF stands for (R)ich (T)ext (F)ormat
So an RichTextBox means it uses RTF as the source.
If you look at the control you will find a .Text and a .TextRTF.
The first is a straight ASCII of what you entered and the second is a "formatted" version in RTF (ie includes places where you chose to BOLD, color, underline etc)
RichTextBox is same as RTF. It can hold very much. Here is how to load or save an RTF file using the RichTextBox Control.
If you want to load/save any text file:Code:'Load File
RichTextBox1.LoadFile "C:\file.rtf", rtfRTF
'Save File
RichTextBox1.SaveFile "C:\file.rtf", rtfRTF
Code:'Load File
RichTextBox1.LoadFile "C:\file.txt", rtfText
'Save File
RichTextBox1.SaveFile "C:\file.txt", rtfText
I tried the RTF box,
Works, but it's far less efficient than TextBox (for what I'm doing). I'm generating sequences of numbers (lottery numbers) and wanted to display them all in a TextBox. Problem is that I was going to put up to 14Millions of combinations in a Box (all possible combinations in 6/49). I was playing with only 500 combinations (15000 chars) and that took about 12 seconds to load into a regular TextBox, but TWICE AS LONG with the RTF box, so I need to find a better solution for displaying the combinations. I'm running a Pentium 233MMX/128MB ram.
Any suggestions?
carefull with these, don't increment the rtfbox itself
Rtfbox.text = rtfbox.text & MyString
That, in a large loop will run very poorly
If you're working with over 10,000 strings (or looping in more than that) then use two or more steps
eg looping the val out of an array
It looks awkward but the performance increase is VERY noticable (which is the point of a perfomance increase) appending to long strings is slow in VB so what you are doing is limiting it's size, much better to use more small strings than one big one. Test the speed difference with 1 tmpstring vs 2, very big difference. And even 1 is bigger than just appending to the RTFbox directlyCode:
Dim TmpString1 As String
Dim TmpString2 As String
For MyLoop = 1 to 20000
TmpString1 = TmpString1 & StrArray(MyLoop)
If MyLoop Mod 500 = 0 then
TmpString2 = TmpString2 & TmpString1
TmpString1 = ""
End If
Next
RTFBox.Text = TempString2 & TempString1
Cheers