[RESOLVED] RichTextBox save edits
with the RichTextBox, I am reading in text from a file with .LoadFile
and saving it again with .Savefile
2 problems:
-I want to programmatically add lines of text to the beginning of the RTBox
How do I insert at the beginning?
-I want to also let the user add text (anywhere) and save all the text.
user text can be added on screen OK, but when I save/load the file the user text is missing !
Re: RichTextBox save edits
Insert at the beginning:
Code:
Dim InsText As String
InsText = "Line 1 " & vbNewLine & "Line 2" ' or whatever
RTB1.Text = InsText & RTB1.Text
Don't understand your 2nd point
Re: RichTextBox save edits
You can also set SelStart and SelLength to 0, then set SelText to the text to be inserted at the beginning. Much faster and cheaper than dragging out all of the text then storing it all back in there.
Re: RichTextBox save edits
for problem #2:
-I want to also let the user add text (anywhere) and save all the text.
user text can be added on screen OK, but when I save/load the file the user text is missing !
The user can type text into the RTBox (along with computer generated text)
but if I save the RTB text to a file & reload it, the user text is missing.....
Re: RichTextBox save edits
what is the code you are using that is not working correctly?
Re: RichTextBox save edits
This is what I am doing:
Code:
RTBlog.LoadFile nameoffile, rtfRTF
RTBlog.SelLenght =0
RTBlog.SelStart = 0
RTBlog.SelText = "text to add by computer" & VBNewLine
and later....
Code:
RTBlog.SaveFile nameoffile, rtfRTF
When I later reload from the file with .LoadFile again, any text entered into the RTBox by the user is lost.
Re: RichTextBox save edits
Found my problem!
I wasn't saving the RTB data to file on form exit....
everything working great. thanks for help