RichTextBox is running my computer out of Memory

dmfolsom
dmfolsom used Ask the Experts™
on
OS: Windows 2000 and Windows XP
VB5 Service Pack 3

I have an application that loads a Rich Text Box with a .Rtf file every ten seconds.
rtbWelcome.LoadFile fileWelcome_Docs.Path + "\" + fileWelcome_Docs.List(MyCounter), rtfRTF
These files were created in Word then converted to Richtext format to be displayed in the RichText Box.
These files contains Text, Inserted Pictures and other Graphics.

After displaying the RTB for ten seconds, it is cleared using rtbWelcome.TextRTF = ""
The memory used by the RTB is partially cleared, however the majority is not. When the application loads the next file the memory used by the application is increased until the point the the computer runs out of resources and crashes.

How do I recover all memory each time I unload the file?
Would there be a better format to display these files to computers that don't have word installed?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Make sure the RTB has it's text property set to "" as the default then try

Option Explicit
Dim strRTB As String
Private Sub Command1_Click()
  RichTextBox1.TextRTF = strRTB
End Sub

Private Sub Form_Load()

strRTB = RichTextBox1.TextRTF

End Sub
That or try setting both text properties to ""
rtbWelcome.TextRTF = ""
rtbWelcome.Text = ""

Author

Commented:
Thanks for the response!

I use the second option befor each load:
rtbWelcome.TextRTF = ""
rtbWelcome.Text = ""
rtbWelcome.LoadFile fileWelcome_Docs.Path + "\" + fileWelcome_Docs.List(Saf), rtfRTF
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Thanks for the response!

I use the second option before each load:
rtbWelcome.TextRTF = ""
rtbWelcome.Text = ""
rtbWelcome.LoadFile fileWelcome_Docs.Path + "\" + fileWelcome_Docs.List(Saf), rtfRTF

Still incrementing up the memory used.  Any other suggestions?
Did youtry the first example where you save off an empty rtf then copy that into the rtf

Author

Commented:
I really appreciate you involvement!

I tried it this way first:
'rtbWelcome.TextRTF = ""
'rtbWelcome.Text = ""
rtbWelcome.TextRTF = strRTB

Then switched to this:

rtbWelcome.TextRTF = ""
rtbWelcome.Text = ""
rtbWelcome.TextRTF = strRTB

Still incrementing the memory.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial