By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,481 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,481 IT Pros & Developers. It's quick & easy.

HELP: writing to RichTextBox

P: n/a


I have been working on this piece of code that's supposed to read from a
file - transform - preview and finally save the transformed data.

I can read the file and with RichtextBox.LoadFile( ) i can display it on
the first box.

Then, in a for loop i read line by line , extract the information and (the
idea is) to put the transformed data in another RichText Box so that the
user can decide wether to save them in a file or not.

However i noticed that with files of around 1Meg and more , the process
slows down and freezes ! There is no exception raised, or i don't see it in
my Try block ... , the MaxSize for the textbox cannot be increased futher,
and I have tried everything except calling the CG explicitly but i don't see
the point in this piece of code.

Please help. I have spend hours on this and can't figure out what could be


************************************************** *****************

Try 'Put writing loop in a try-catch block


'Main Loop over all lines of Global ArrayList

'------------- STEP 1 ------------------------

' -- READ data from global array into structure

For Each LineStr In globalArrayListIN

'Check each line length IF different than 233

If (LineStr.Length = 234 Or LineStr.Length = 233) Then

'increase progress bar

pbrTransform.Value += 1

'extract Station ID , year , month , element code

tempLine.stationID = LineStr.Substring(0, 7)

tempLine.year = LineStr.Substring(7, 4)

tempLine.month = LineStr.Substring(11, 2)

tempLine.element = LineStr.Substring(13, 3)

'Loop in order to get data for the 31 days of the month on the same line

For i As Integer = 0 To 30

tempLine.value(i) = LineStr.Substring(16 + (i * 7), 7)


'------------- STEP 2 ------------------------

'-- ADD lines to the Transformed preview pane


rtbTransformed.AppendText(delimiter + tempLine.year)

rtbTransformed.AppendText(delimiter + tempLine.month)

rtbTransformed.AppendText(delimiter + tempLine.element)

For i As Integer = 0 To 3

rtbTransformed.AppendText(delimiter + tempLine.value(i))



'IF file format is NOT correct, advise user and exit loop


MsgBox("Le fichier n'as pas le propre format de 234 characters par ligne." +
vbCrLf + "SVP essayer de nouveau.")

Exit For

End If


Catch ex As Exception



pbrTransform.Value = 0 'clear progress bar

End Try
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.