Question on pure visual basic
-
hi, anyone kindly help me out? i want to load multiple files using richtextbox loadfile option(rtf.LoadFile) and all the contents of the files will come one by one and shown in the richtextbox in lines.there may be informations from the database also.what i'm doing, every time, the last file is loaded and overridden on the previous one.thus the contents of the last file being loaded are shown.i think if i can insert a newline between files being loaded then it will work.but standard newline property like vbcrlf didn't work.kindly help.this is urgent.thank you for reading this problem patiently.
-
hi, anyone kindly help me out? i want to load multiple files using richtextbox loadfile option(rtf.LoadFile) and all the contents of the files will come one by one and shown in the richtextbox in lines.there may be informations from the database also.what i'm doing, every time, the last file is loaded and overridden on the previous one.thus the contents of the last file being loaded are shown.i think if i can insert a newline between files being loaded then it will work.but standard newline property like vbcrlf didn't work.kindly help.this is urgent.thank you for reading this problem patiently.
The reason your text is getting over-written is because LoadFile scraps everything in the control before the new file is loaded. Your going to need 2 RichTextBoxes, one visible, and one not. What you do is tell the hidden RichTextBox to do the LoadFile, then copy and paste the contents of the hidden RichTextBox to the Visible one. Add your blank line to the end of the visible RichTextBox, start over again. Here is a little pseudo-code:
' RichTextBox1 is Visible, RichTextBox2 is not.
' And make sure RichTextBox1 is cleared of text first.
RichTextBox1.Visible = True
RichTextBox2.Visible = False
RichTextBox1.Clear()' Now, for each filename:
' Have the hidden RTB (RichTextBox2) load the file we want
' then, select all the text in it
' then, tell the visible RTB (RichTextBox1) to Append the SelectedText in the hidden RTB
' and then, append a blank line to the bottom of the text.
For Each Filename
RichTextBox2.LoadFile(filename)
RichTextBox2.SelectAll()
RichTextBox1.AppendText(RichTextBox2.SelectedText)
RichTextBox1.AppendText(vbCrLf)
NextRageInTheMachine9532