-
Jun 19th, 2021, 02:58 AM
#1
Thread Starter
PowerPoster
[RESOLVED] read content in richtexbox line by line and save in c:\mydir\test.txt
read content in richtexbox line by line and save in c:\mydir\test.txt
????
Instead other way are welcome.
in effect i need to print all lines from richtexbox and insert in txt.
-
Jun 19th, 2021, 03:45 AM
#2
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Code:
Dim Lines() As String
Dim c As Long
Lines = Split(RichTextBox.Text, vbCrLf)
For c = 0 To UBound(Lines)
Debug.Print Lines(c)
Next
-
Jun 19th, 2021, 04:42 AM
#3
Thread Starter
PowerPoster
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by Eduardo-
Code:
Dim Lines() As String
Dim c As Long
Lines = Split(RichTextBox.Text, vbCrLf)
For c = 0 To UBound(Lines)
Debug.Print Lines(c)
Next
work! tks.
But why to the end of txt file have a blank line? I dont need!
-
Jun 19th, 2021, 06:19 AM
#4
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by luca90
work! tks.
But why to the end of txt file have a blank line? I dont need!
It must be that the text has a carriage return at the end, aka a blank line.
-
Jun 19th, 2021, 06:50 AM
#5
Thread Starter
PowerPoster
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by Eduardo-
It must be that the text has a carriage return at the end, aka a blank line.
OK
but possible to not have?
-
Jun 19th, 2021, 07:06 AM
#6
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by luca90
OK
but possible to not have?
You could always just check if the last line is a blank line and if so then don't write it out.
-
Jun 19th, 2021, 07:20 AM
#7
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Why write it line by line? Why not just write it all at once?
Code:
Print #1, Richtextbox1.Text;
the ; on the end prevents the print statement from adding a crlf at the end
-
Jun 19th, 2021, 08:54 AM
#8
Thread Starter
PowerPoster
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by PlausiblyDamp
You could always just check if the last line is a blank line and if so then don't write it out.
????
-
Jun 19th, 2021, 09:01 AM
#9
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by luca90
OK
but possible to not have?
Ok:
Code:
Dim Lines() As String
Dim c As Long
Lines = Split(RichTextBox.Text, vbCrLf)
c = UBound(Lines)
Do While Lines(c) = ""
c = c - 1
Loop
ReDim Preserve Lines(c)
For c = 0 To UBound(Lines)
Debug.Print Lines(c)
Next
Last edited by Eduardo-; Jun 19th, 2021 at 09:05 AM.
-
Jun 19th, 2021, 03:45 PM
#10
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Code:
RichTextBox.SaveFile "saved.txt", rtfText
Bam! All done.
-
Jun 19th, 2021, 07:11 PM
#11
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by dilettante
Code:
RichTextBox.SaveFile "saved.txt", rtfText
Bam! All done.
Doesn't that save it in rtf format?
-
Jun 20th, 2021, 12:55 PM
#12
Re: read content in richtexbox line by line and save in c:\mydir\test.txt
Originally Posted by DataMiser
Doesn't that save it in rtf format?
No, explicitly asking for text format doesn't save in RTF format.
-
Jun 20th, 2021, 08:05 PM
#13
Re: [RESOLVED] read content in richtexbox line by line and save in c:\mydir\test.txt
Been a long time since I used it, the rtfText on the end made me think it was calling for rtf format.
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
|