Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / July 2008



Tip: Looking for answers? Try searching our database.

Text box that holds more then 64K characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bu - 03 Jul 2008 08:21 GMT
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
NeilH - 03 Jul 2008 09:09 GMT
> 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

RichTextBox
expvb - 03 Jul 2008 16:02 GMT
>> 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?

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 <> 0 Then
       ' EM_SETTEXTMODE failed
       Debug.Print _
           "EnableTextMode: EnablePlainTextMode failed, LastDllError = " &
_
           Err.LastDllError
   End If
End Sub
Larry Serflaten - 03 Jul 2008 12:32 GMT
> 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?

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
Bu - 03 Jul 2008 20:08 GMT
>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

All,
Rhanks for the responses.

Bu
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.