|
-
Oct 31st, 1999, 07:18 PM
#1
Thread Starter
New Member
I know how to save information in a richtextbox to file, but the code doesn't work for a text box. Any suggestions?
-
Oct 31st, 1999, 07:53 PM
#2
Lively Member
To save data from a text box (text1)
open "Myfile.txt" for output as 1
print #1,text1.text
close #1
If the text box is not multiline, this gives 1 line in the file. If it is multiline, then it gives lots of lines
Cheers
Chris
-
Nov 3rd, 1999, 08:28 PM
#3
Thread Starter
New Member
-
Jul 25th, 2000, 04:25 AM
#4
Member
doesn't work??
I tried this code, but it's not 100% working with the rich text box. Sometimes all the Cr and Lf are gone and the file has only one line, and other times the cr and lf are there. strange~~~
Please Visit My WebCam!!
http://www.hmcheung.com
-
Jul 25th, 2000, 04:33 AM
#5
Member
From Help File(RichTextBox Control) :
You can easily open or save an RTF file with the RichTextBox control by using the LoadFile and SaveFile methods. To open a file, use a CommonDialog control to supply the path name as shown:
Private Sub OpenFile()
' The RichTextBox control is named "rtfData."
' The CommonDialog is named "dlgOpenFile."
' Declare a String variable for file name.
' Show the Open File dialog box, and set the
' variable to the filename.
Dim strOpen As String
dlgOpenFile.ShowOpen
strOpen = dlgOpenFile.FileName
' Use LoadFile method to open the file.
rtfData.LoadFile strOpen
End Sub
To save a file is just as easy, using the SaveFile method:
Private Sub SaveFile()
Dim strNewFile As String
dlgOpenFile.ShowSave
strNewFile = dlgOpenFile.FileName
rtfData.SaveFile strNewFile
End Sub
-
Jul 25th, 2000, 05:02 AM
#6
Member
Thanks
Thanks for your reply. The most crucial part is the .savefile method. the above code is also using this method and the problem is that the resulting txt file will lose all the formatting....
Please Visit My WebCam!!
http://www.hmcheung.com
-
Jul 25th, 2000, 09:15 AM
#7
To keep the formatting, pass rtfRTF as the flag.
Code:
RichTextBox1.SaveFile "C:\MyFile.rtf", rtfRTF
If you want to save in plain text format (ASCII), pass rtfText as the flag.
Code:
RichTextBox1.SaveFile "C:\MyFile.rtf", rtfText
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|