View Single Post
  #7 (permalink)  
Old July 25th, 2003, 02:49 AM
alex_read alex_read is offline
Authorized User
Join Date: Jul 2003
Location: Reading, Berkshire, United Kingdom.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alex_read

I think I've understtod this right & here's my take on the above, let me know if this isn't what you're after:

Private Const cstrFILETOCHECK As String = "C:\SampleFile.txt"
Private Const cstrFILETOWRITETO As String = "C:\2ndSampleFile.txt"

Private Sub Form_Load()
    Dim straryRetFileLines() As String
    Dim lngElementCount As Long
    Dim blnOkToAddFileLine As Boolean
    Dim strCurrentFileLine As String

    lngElementCount = 0
    blnOkToAddFileLine = False

    Open cstrFILETOCHECK For Input As #1
        Do While Not EOF(1)
            Line Input #1, strCurrentFileLine

            If (lngElementCount = 0) Then
                blnOkToAddFileLine = True
            ElseIf Not (CStr(Trim(strCurrentFileLine)) = straryRetFileLines(lngElementCount - 1)) Then
                blnOkToAddFileLine = True
                blnOkToAddFileLine = False
            End If

            If (blnOkToAddFileLine = True) Then
                ReDim Preserve straryRetFileLines(lngElementCount)
                 straryRetFileLines(lngElementCount) = CStr(Trim(strCurrentFileLine))

                lngElementCount = lngElementCount + 1
            End If
    Close #1

    strCurrentFileLine = ""

    For lngElementCount = 0 To UBound(straryRetFileLines)
        strCurrentFileLine = strCurrentFileLine & straryRetFileLines(lngElementCount) & vbCrLf
    Next lngElementCount

    Open cstrFILETOWRITETO For Output As #2
        Print #2, strCurrentFileLine
    Close #2

    MsgBox "Done!!"
    Unload Me
End Sub
Reply With Quote