Discussions Search    Reviews    Search Aid    Buzzzz    Google@Omgili Add to iGoogle   Bookmark and Share

  Advanced Search



Text box that holds more then 64K characters

On Thu, 03 Jul 2008 09:21:17 +0200, Bu <...@si.si

Hello

In VB6 the textbox can hold up to 65536 characters. Is there a box/dll
that comes with VB6 that does not have this limit?

Bu

 Latest discussions from this group  (microsoft.public.vb.general.discussion)

TextBox Update Problem  
[27 Aug 2008]
On Wed, 27 Aug 2008 14:00:52 -0700 (PDT), WynnGIS <timwynn@bellsout h.net Hello! I’m ...
new to VB and need some help. 1st: I’m I posting to the correct group? 2nd: I have a small...
Adodc File Error  
[27 Aug 2008]
On Wed, 27 Aug 2008 06:28:00 -0700, LondonLad <LondonLad@discus sions.microsoft.com Hi...
Those that help on a regular basis will know this, but to try and explain I will say it ...
Form load failure  
[27 Aug 2008]
On Wed, 27 Aug 2008 12:10:02 -0500, "jpm" <uh@nojunkfromlos ers.andmorons VB6 Problem...
Calling a standard form (e.g. Form1.Load) from the 'main' form in an application. The...
More...


On Thu, 3 Jul 2008 06:32:05 -0500, "Larry Serflaten" <...@usinternet.com


"Bu" <...@si.si

64K is not a limit of the textbox, it is more a limit of the textbox interface.
If handled carefully, you can put more than 65536 characters in a normal
textbox. For an example, add a textbox to a new form and set its
MultiLine property to True and its Scrollbars property to 2 (Vertical).
then paste in the following code and try it out....

LFS

Private Sub Form_Load()
Dim txt As String
Dim lin As Long, ofs As Long

' Build a large string of text
txt = "This is line # " & vbCrLf & Space$(2500004)
Mid(txt, 27) = txt
lin = 1
For ofs = 16 To Len(txt) Step 26
Mid(txt, ofs) = CStr(lin)
lin = lin + 1
Next

' Assign it to the textbox (SelText)
Text1.Text = ""
Text1.SelText = txt
Text1.SelText = "This is the last line."

' Check its length (2,500,052 characters!)
MsgBox "Text1.Text length = " & CStr(Len(Text1.Text))
End Sub


On Thu, 3 Jul 2008 09:09:51 +0100, "NeilH" <...@nospam.uk


"Bu" <...@4ax.com...

RichTextBox


On Thu, 3 Jul 2008 11:02:43 -0400, "expvb" <...@cox.net


The underlying control used by the text box was limited in Windows 9x to
64K. This has increased in NT4 and after to the amount of available memory,
but VB6 still treat it at 64K max, but you could get around this as Larry
mentioned.

RichTextBox Control is not limited to 64K, but the text is treated as RTF by
default. I am not sure if there is a property that you can set to make it
ignore RTF codes, but you can send EM_SETTEXTMODE to the control to switch
it to plain text mode. Below is a sample code to do that, however, it seems
there is a bug in the control when you paste Rich Text to it, so you have to
intercept Ctrl+V and change the text yourself if necessary. Search the
newsgroups for "EM_SETTEXTMODE bug".

Option Explicit

Private Const WM_USER As Long = &H400
Private Const EM_SETTEXTMODE As Long = (WM_USER + 89)

Private Const TM_PLAINTEXT = 1
Private Const TM_RICHTEXT = 2 '/* default behavior */
Private Const TM_SINGLELEVELUNDO = 4
Private Const TM_MULTILEVELUNDO = 8 '/* default behavior */
Private Const TM_SINGLECODEPAGE = 16
Private Const TM_MULTICODEPAGE = 32 '/* default behavior */

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long

Private Sub Form_Load()
EnablePlainTextMode RichTextBox1
End Sub

Private Sub EnablePlainTextMode(ByVal rtf As RichTextBox)
Dim ret As Long

' RichTextBox must be empty before changing the mode
rtf.Text = ""
ret = SendMessage(rtf.hwnd, EM_SETTEXTMODE, _
TM_PLAINTEXT Or TM_MULTILEVELUNDO Or TM_MULTICODEPAGE, ByVal 0&)
Debug.Print "EnablePlainTextMode: EM_SETTEXTMODE returned " & ret
If ret < ' EM_SETTEXTMODE failed
Debug.Print _
"EnableTextMode: EnablePlainTextMode failed, LastDllError = " &
_
Err.LastDllError
End If
End Sub




On Thu, 03 Jul 2008 21:08:00 +0200, Bu <...@si.si

On Thu, 03 Jul 2008 09:21:17 +0200, Bu <...@si.si

All,
Rhanks for the responses.

Bu

Discussion Title: Text box that holds more then 64K characters
Title Keywords: Text  that  holds  more  then  characters