PDA

Click to See Complete Forum and Search --> : save a return delimeted line


badgers
Jan 11th, 2000, 03:59 AM
this is associated with my paragraph indent topic.
Using a rich text box I can get the indention I need. my question is how can I save the contents of the rich text box one line at a time. I would need to convert any indention to spaces.
I need it a line at a time so that I can place a return at the end of each line.


------------------
I am so skeptacle, I can hardly believe it!

Aaron Young
Jan 11th, 2000, 04:20 AM
Try something like:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_GETLINE = &HC4
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1

Private Sub Command1_Click()
Dim iFile As Integer
Dim lLines As Long
Dim lIndex As Long
Dim sLine As String
Dim lLen As Long
Dim lHwnd As Long

iFile = FreeFile
lHwnd = RichTextBox1.hwnd
Open "C:\Saved.txt" For Output As iFile
For lLines = 0 To SendMessage(lHwnd, EM_GETLINECOUNT, 0&, ByVal 0&) - 1
lIndex = SendMessage(lHwnd, EM_LINEINDEX, lLines, ByVal 0&)
lLen = SendMessage(lHwnd, EM_LINELENGTH, lIndex, ByVal 0&)
sLine = Space(lLen)
Call SendMessage(lHwnd, EM_GETLINE, lLines, ByVal sLine)
Print #iFile, Left$(sLine, lLen)
Next
Close iFile
End Sub


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

badgers
Jan 11th, 2000, 04:51 AM
thanks for your time Aaron Young. When I run the code it looses the indentions.
If I have a six line paragraph that is indented only the first line is indented and the rest fill the line.
The RichTextBox looks like this
****the RTB is only this wide----|

Section Title:
***this is an example of how
***the text looks on the
***screen. but I cant save it
***as a text file!

and the text file looks like this:

Section Title:
***this is an example of how
the text looks on the screen.
but I cant save it as a text
file!

in the text file the paragraph is indented by a tab.
thank you Aaron for your help and I appreciate your time.

------------------
I am so skeptacle, I can hardly believe it!


[This message has been edited by badgers (edited 01-11-2000).]

badgers
Jan 13th, 2000, 02:57 AM
in this API call is is possible to determine if the line is indented. I have stepped through the code and the text that gets returned does not seem to have any characters in it. Is there a different API call to determine if a specific line has been indented so that when I read the line I can add spaces to the front of it? Also, it would help to know how much indention there is, ie two levels of indention or one