Hi everyone,
I can use the RichTextBox.savefile and the RichTextBox.loadfile but the loadfile will not load the same file as the save file and I can't figure out how to copy the savefile to the loadfile for loading. Sounds stupid doesn't it? Can someone help?
This should be straightforward - show us some code!
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
'Now, the file is copied but it over writes the old file
'Cannot figure out how to append to the file so that the
'old text is not lost
RichTextBox1.LoadFile OutFile, rtfRTF
The loadfile and savefile methods are a good solution when you want to load or save the entire contents of a file. At times, however, you might want to append the contents of the control to an existing file or store multiple portions of text in the same file. In such cases you can use the TextRtf property with regular visual basic file commands and functions.
----Programming VB 6 by Francesco Balena Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
Sorry but I'm having trouble seeing what you're trying to do.
There appears to be no appending or saving going on that's related to RichTextBox1.
It looks like you load InputFile2 into RTB1, then immediately overwrite InputFile2 with InputFile, then load the copied file straight back into the RTB1.
Have I missed something?
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
Let me try again to append to a file and get back to both of you. John, the filecopy method was used because my append try didn't work. I will use the TextRTF property this time.
The following code does not append to the file. I wonder if the LoadFile method of the RTB is locking the file and not allowing the append to take place? Any ideas?:
Dim OutFile As String
Private Sub Command1_Click()
NewStr = RichTextBox2.TextRTF
Open OutFile For Append As #3
Write #3, NewStr
Close #3
End Sub
Private Sub Form_Load()
OutFile = "C:\VB Projects\Test\RichTxtBox\OutputFile.rtf"
RichTextBox1.LoadFile OutFile, rtfRTF
Call Timer1_Timer
End Sub
Private Sub Timer1_Timer()
DoEvents
RichTextBox1.LoadFile OutFile, rtfRTF
Timer1.Interval = 2001
End Sub
dim tmp as variant
open "c:\yourfile.rtf" for binary as #1
tmp = richtextbox1.textRTF: put #1 ,,tmp
tmp = richtextbox2.textRTF: put #1,,tmp
close #1
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.