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

TextBox out of memory 1

Status
Not open for further replies.

Schroeder

MIS
Sep 25, 2001
382
US
Is there a practical limit to the amount of text being displayed in a text box? I'm trying to display the results of a report in a text box. I get an Out of Memory error somewhere after 200 lines or so are added to the box. I tried creating the whole report within a string variable but when I move the string into the text box.. Out of Memory. Certainly 200 lines of text do not occupy that much memory.
If I'm hitting some defined limit of text boxes, does anyone have an alternative?
 
Hi,

msdn states:

The Text setting for a TextBox control is limited to 2048 characters unless the MultiLine property is True, in which case the limit is about 32K.

Jon
 
I have used the Webbrowser control to display large text files and it works pretty slick. If that is something you would consider using, I can post some code. Let me know. Anything is possible, the problem is I only have one lifetime.
[cheers]
 
Sure. I'd appreciate it.
I've been trying to use the RichTextBox control for the first time. Seems like it would work except that it appears to be word-wrapping and I don't see where I can turn that off. It has a horizontal scroll bar so there must be a way to disable word wrap.
 
OK here you go.

Private oDoc As Object

I used a common dialog box called "dlgOpen" to open the text file, a webbrowser control named "wbDocument", and create a blank text file to speed up the webbrowser controls loading.

Private Sub Form_Load()
Dim fso As New FileSystemObject, FilePath, txtfile, Stream

On Error GoTo ErrHnd

If Not fso.FileExists(App.Path & "\Blank.txt") Then
fso.CreateTextFile (App.Path & "\Blank.txt")
End If

With dlgOpen 'Dialog Box For Finding File To Edit
.Filter = "text files " & "(*.txt) | txt"
.FilterIndex = 1
.Flags = cdlOFNFileMustExist Or cdlOFNHideReadOnly
End With
wbDocument.Navigate App.Path & "\Blank.txt
Exit Sub

ErrHnd:
MsgBox Err.Number & " " & Err.Description & " Error Generated By " & Err.Source, vbCritical, "System Error Trap !"
End Sub

A command button named "cmdOpen" to open the common dialog box

Private Sub cmdOpen_Click()
Dim sFile As String

On Error GoTo ErrHnd

With dlgOpen
.FileName = ""
.ShowOpen
sFile = .FileName
End With

If Len(sFile) Then
Set oDoc = Nothing
wbDocument.Navigate sFile
End If
Exit Sub

ErrHnd:
MsgBox Err.Number & " " & Err.Description & " Error Generated By " & Err.Source, vbCritical, "System Error Trap !"
End Sub

You will need to make some modifications to the code to open the text file you create but this should get you started. Good luck. Anything is possible, the problem is I only have one lifetime.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top