Results 1 to 10 of 10

Thread: TXT File open, modify, save as new (RESOLVED)

  1. #1

    Thread Starter
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143

    Resolved TXT File open, modify, save as new (RESOLVED)

    got this to start off

    Code:
    Private Sub mnuConvert_Click()
    
    Call mnuCloseLog_Click 'Close Log file first
    
    Open Temp For Input As #1 'Open log file
    
        Open NewLogFile For Append As #2
    
        Close #2
    
    Close #1
    
    End Sub
    want to open a log file, stored in (Temp) delete the  then save to another file (NewLogFile), whats the best way to do this, please use code i already have and decare any variables

    thanks in advance
    Last edited by Robbo; Dec 14th, 2004 at 11:21 AM.
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

  2. #2

    Thread Starter
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143

    Re: TXT File open, modify, save as new

    ok got this

    Code:
    strFind = "" 'What To find
    strReplace = "" 'What To replace it With
    strDestination = CommonDialog1.FileName 'Where To put the files once they have been modified
    strSource = Temp 'Where To Get the files
    strFilter = "*.txt" 'wildcards
    'verification complete
    Dim Parse As String
    Dim Hold As String
    'FIND AND REPLACE
    Open strSource For Input As #1 'Open log file
        Do While Not EOF(1)
            Line Input #1, Parse
            'Hold = Hold & replace(Parse, strReplace, strFind)
            Hold = Hold & replace(Parse, strFind, strReplace)
        Loop
    
    Open strDestination For Output As #2
    Print #2, Hold
    Close #2
    Hold = ""
    Parse = ""
    Close #1
    but it doesnt seem to be working, not taking out the  in txt files??, however need the txt files as is with the line feed and character returns

    please help
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

  3. #3
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: TXT File open, modify, save as new

    strFind = Chr$(0) 'What To find

    I think it is null
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  4. #4

    Thread Starter
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143

    Re: TXT File open, modify, save as new

    nope that didnt work, also i seem to be losing my return(enter) and string fits on 2 lines where i want to have as original txt file (log) as attached without the squares in
    Attached Files Attached Files
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

  5. #5
    Hyperactive Member mudfish's Avatar
    Join Date
    Feb 2004
    Location
    Chit Chat
    Posts
    353

    Re: TXT File open, modify, save as new

    VB uses ascii 10 and 13 for vbCrLf
    Word only uses 10.
    Not sure about a .txt
    Mudfish AKA Bowfin
    I can spell "If" all day right, just a coder!


    "Always do sober what you said you'd do drunk. That will teach you to keep your mouth shut." -- Ernest Hemingway

    Member of the ECCC

  6. #6
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    Bahrain
    Posts
    306

    Re: TXT File open, modify, save as new

    I have made one for along time. Create File, Append and Open File. If it's help please let me know.

    thanks.
    Habibalby
    Attached Files Attached Files

  7. #7
    Junior Member
    Join Date
    Oct 2004
    Posts
    16

    Re: TXT File open, modify, save as new

    is it possible to write a string to file without the (") sign???

  8. #8

    Thread Starter
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143

    Resolved Re: TXT File open, modify, save as new

    sorry havent used your code but got this working

    Code:
    strReplace = "" 'What To replace it With
    strDestination = CommonDialog1.FileName 'Where To put the files once they have been modified
    strSource = Temp 'Where To Get the files
    strFilter = "*.txt" 'wildcards
    'verification complete
    Dim Parse As String
    Dim Hold As String
    'FIND AND REPLACE
    Open strSource For Input As #1 'Open log file
        Open strDestination For Output As #2
        Do While Not EOF(1)
            Line Input #1, Parse
            'Hold = Hold & replace(Parse, strReplace, strFind)
            'strFind = Chr(10) 'What To find
            Hold = replace(Parse, "", strReplace)
            Hold = replace(Hold, "", strReplace)
            Hold = replace(Hold, "", strReplace)
            Print #2, Hold
        Loop
    Hold = ""
    Parse = ""
    Close #1
    Close #2
    cheers
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

  9. #9
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    Bahrain
    Posts
    306

    Re: TXT File open, modify, save as new (RESOLVED)

    Congratulations

  10. #10

    Thread Starter
    Frenzied Member Robbo's Avatar
    Join Date
    Jan 2001
    Location
    Bradford
    Posts
    1,143

    Re: TXT File open, modify, save as new (RESOLVED)

    thanks will be back on next problem
    -----------------------------------------------
    "The hall is rented,"
    "the orchestra is engaged,"
    "its now time to see if you can dance!"
    Q, Q-Who, Star Trek The Next Generation
    -----------------------------------------------
    General Work day

    -----------------------------------------------
    DOS, Win 95, Win 98 SE, Win ME, Win NT 4.0 SP6a, Windows 2000 SP3, Window XP SP1, Windows 7, Windows 8/8.1, Windows 10, Office 97 Pro, Office 2000 Pro, Office 2010, Office 2013, Office 2016, Office 2019, Visual Basic 6 (SP5), SQL, Oracle

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