Results 1 to 9 of 9

Thread: [RESOLVED] How i need save Text 1 Each line separate

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    134

    Resolved [RESOLVED] How i need save Text 1 Each line separate

    Hi Everyone,

    How i need save Text Each line separate




    when click save i need come like this




    No Need come like this


  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: How i need save Text 1 Each line separate

    Code:
    Open pathname For Append As [#]filenumber
    From what you've given us, that's about the best I can do. That certainly gives you a way to save lines in a text file upon each occurrence of some event.

    You say "Save" though. Do you mean "Save to File", or do you mean something else?

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How i need save Text 1 Each line separate

    @Elroy. This looks like the case of wanting to save text, to file, as word-wrapped in the control. But not positive. If so, that's an odd request.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    134

    Re: How i need save Text 1 Each line separate

    i can save file txt but i need save same like this.

    I want each line to be independent



  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: How i need save Text 1 Each line separate

    This sounds very strange. I suppose if you really want to do such a thing you might crack open that fine manual though. Everything you need is in the MSN Library docs that come with legal copies of VS/VB 6.0:

    Code:
    Option Explicit
    
    Private Const EM_GETLINECOUNT As Long = &HBA&
    Private Const EM_GETLINE As Long = &HC4&
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" ( _
        ByVal hWnd As Long, _
        ByVal wMsg As Long, _
        ByVal wParam As Long, _
        ByVal lParam As Long) As Long
    
    Private Sub Form_Load()
        Dim F As Integer
    
        F = FreeFile(0)
        Open "original.txt" For Input As #F
        Text1.Text = Input$(LOF(F), #F)
        Text1.SelStart = 0
        Close #F
    End Sub
    
    Private Sub Form_Resize()
        If WindowState <> vbMinimized Then
            With Text1
                .Move 0, 0, ScaleWidth / 2, ScaleHeight
                Text2.Move .Width, 0, ScaleWidth - .Width, .Height
            End With
        End If
    End Sub
    
    Private Sub mnuGo_Click()
        Const MAX_WIDTH As Long = 2048 'Some reasonable value, or you could use a varying
                                       'length buffer by querying with EM_LINEINDEX and
                                       'then EM_LINELENGTH for each line as you go.
        Dim LineCount As Long
        Dim LineBuffer As String
        Dim I As Long
        Dim LineChars As Long
        Dim F As Integer
    
        LineCount = SendMessage(Text1.hWnd, EM_GETLINECOUNT, 0, 0)
        LineBuffer = Space$(MAX_WIDTH)
        With Text2
            .Visible = False
            .Text = vbNullString
            For I = 0 To LineCount - 1
                Mid$(LineBuffer, 1, 1) = ChrW$(MAX_WIDTH)
                LineChars = SendMessage(Text1.hWnd, EM_GETLINE, I, StrPtr(LineBuffer))
                .SelText = Left$(LineBuffer, LineChars)
                .SelText = vbNewLine
            Next
            .SelStart = 0
            .Visible = True
    
            F = FreeFile(0)
            Open "reformatted.txt" For Output As #F
            Print #F, .Text;
            Close #F
        End With
    End Sub

    Name:  sshot1.png
Views: 167
Size:  6.6 KB

    Start


    Name:  sshot2.png
Views: 167
Size:  7.5 KB

    Click "Go"


    Name:  sshot3.png
Views: 166
Size:  8.9 KB

    Drag Form wider to show the new formatting


    But perhaps I completely misread the question?
    Attached Files Attached Files

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    134

    Re: How i need save Text 1 Each line separate

    Thank you so much dilettante.

    Now is ok

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    134

    Re: [RESOLVED] How i need save Text 1 Each line separate

    Hi Everyone,

    i Have small problem

    I have a comma delimited text file from which I'm reading. After I work the contents of each line & determine it's not a blank line, I write that line into a new text file. So the new file is the same as the original, except any blank lines have been removed.

    My problem is that there is always a blank line at the end of the new file. The program that uses this new text file raises an error if there is a trailing blank line.


    I try remove this line, If you remove this line will come problem, all lines will merge.
    Code:
    .SelText = vbNewLine
    Last edited by coldlove; Apr 29th, 2018 at 04:14 PM.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2017
    Posts
    134

    Re: [RESOLVED] How i need save Text 1 Each line separate

    There is no solve for this problem?

  9. #9
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: [RESOLVED] How i need save Text 1 Each line separate

    Use If Right$(MyTextVariable, 2) = vbNewLine Then to test if the text ends with an empty new line (note that the "marker" for new line is 2 characters long).

    Use MyTextVariable = Left$(MyTextVariable, Len(MyTextVariable) - 2) to cut off the last two characters from your text.

    cheers,
    </wqw>

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