<-- Previous || Up || Next -->

Every Nth File Line Sample Sub
Utilities Class

Private Sub EveryNthFileLineSample()
    Const strFn = "EveryNthFileLineSample"

    Dim strEveryNthLine As String
    strEveryNthLine = InputBox("Copy every Nth line: ({Esc} cancels.)", strFn, "25")
    If Len(strEveryNthLine) = 0 Then Exit Sub

    Dim strInFile As String
    strInFile = CombinePathAndFile(GetWindowsDirectory, "WIN.INI")
    strInFile = InputBox("Input file: ({Esc} cancels.)", strFn, strInFile)
    If Len(strInFile) = 0 Then Exit Sub

    Dim strOutFile As String
    strOutFile = GetTempFileName(Null, strFn)
    strOutFile = InputBox("Output file: (FILE WILL BE OVERWRITTEN; {Esc} cancels.)", strFn, strOutFile)
    If Len(strOutFile) = 0 Then Exit Sub

    Dim intAddLineNums As Integer
    Select Case MsgBox("Add line numbers?", vbQuestion + vbYesNoCancel + vbDefaultButton1, strFn)
        Case vbYes
            intAddLineNums = True
        Case vbNo
            intAddLineNums = False
        Case vbCancel
            Exit Sub
        Case Else
    End Select

    MsgBox "Return = " & EveryNthFileLine(strEveryNthLine, strInFile, strOutFile, intAddLineNums) & " (True means success; False means failure.)", vbInformation, strFn
End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.