PDA

Click to See Complete Forum and Search --> : text box


badgers
Nov 18th, 1999, 03:34 AM
I have a text box that contains about 200 lines. some are ended by a return and others are word wraped. I need to take the text in this text box and save it as a return delimited file. Is it possible to take each line one at a time and save it out to a file. If the line has a hard return I just save it. If the line was word wrapped I would add a return at the end of the line.
I am doing this so that I can import this text into AutoCAD. I want each line to be 65 characters or less, which is what the text box is displaying.
thank you for your time and have a good day

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

Aaron Young
Nov 18th, 1999, 09:59 AM
Try this, it Outputs the Text As Is..

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_GETLINE = &HC4
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINELENGTH = &HC1

Private Sub Command1_Click()
Dim iLines As Long
Dim iLine As Integer
Dim iFile As Integer
Dim sLine As String

iFile = FreeFile
Open "C:\Export.txt" For Output As iFile
iLines = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&)
For iLine = 0 To iLines - 1
sLine = Space(SendMessage(Text1.hwnd, EM_LINELENGTH, iLine, ByVal 0&))
Call SendMessage(Text1.hwnd, EM_GETLINE, iLine, ByVal sLine)
Print #iFile, sLine
Next
Close iFile
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net