Results 1 to 2 of 2

Thread: text box

  1. #1

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Madison, WI USA


    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!

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Red Wing, MN, USA


    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
        Close iFile
    End Sub

    Aaron Young
    Analyst Programmer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width