Results 1 to 27 of 27

Thread: [RESOLVED] renumber text file

Threaded View

  1. #23

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Re: renumber text file

    Hi all

    I,ve been using this code for a while. i wanted to run through again and remove any empty spaces.

    Can anyone help with this

    Reston

    VB Code *******************
    Private Sub Command3_Click()
    Open App.Path & "\test.t" For Input As 1
    filearr = Split(Input(LOF(1), #1), vbNewLine)
    Close 1
    '''ReDim filearr(30000) ' used for testing
    '''For i = 0 To UBound(filearr)
    ''' filearr(i) = "N " & i + 1
    '''Next
    For i = 0 To UBound(filearr)
    linearr = Split(filearr(i), " ")
    If UBound(linearr) > 0 Then 'check there are enough items in the array
    If IsNumeric(linearr(1)) Then 'check that the current string actually contains a number
    linearr(1) = (linearr(1) + 99998) Mod 99999 + 1 'if over 9999 it will make line 10000 = 1
    ace = 89
    End If
    End If
    filearr(i) = Join(linearr, " ")
    Next
    Open App.Path & "\test.t" For Output As 1 'overwrite original file
    Print #1, Join(filearr, vbNewLine)
    Close 1

    Command1.Enabled = True
    End Sub

    Private Sub Command1_Click()


    Then i run this to remove the space after the N. I would like to have a Separate command button that i can run the remove all spaces.

    Dim FF1 As Integer, FF2 As Integer

    FF1 = FreeFile
    Open App.Path & "\test.t" For Input As #FF1
    FF2 = FreeFile
    Open App.Path & "\test2.t" For Output As #FF2
    Print #FF2, Replace(Input(LOF(FF1), #FF1), vbCrLf & "N ", vbCrLf & "N")
    Close #FF2
    Close #FF1
    End Sub


    Thanks Reston
    Last edited by tiguy; May 23rd, 2007 at 05:03 PM.

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