line replacing ideas

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rodchar

    #1

    line replacing ideas

    hey all,
    i have 2 notepad files and i want to replace every 3rd line in 1 of the
    notepad files with the exact same line in the other notepad file. what's the
    easiest way to do this?

    thanks,
    rodchar
  • Steve Long

    #2
    Re: line replacing ideas

    I'd check out the StreamReader and StreamWriter classes in the
    documentation.. .

    Steve

    "rodchar" <rodchar@discus sions.microsoft .comwrote in message
    news:96C5811B-446C-43EA-A74D-127D370F51B4@mi crosoft.com...
    hey all,
    i have 2 notepad files and i want to replace every 3rd line in 1 of the
    notepad files with the exact same line in the other notepad file. what's
    the
    easiest way to do this?
    >
    thanks,
    rodchar

    Comment

    • Tim Patrick

      #3
      Re: line replacing ideas

      Here's some pseudocode that may meet your needs.

      Dim position As Integer = 0

      Open the first file
      Open the second file
      Open the output file

      While (both input files still have data)
      Read in one line from both input files

      position += 1
      If ((position Mod 3) = 0) Then
      Write out line from second input file
      Else
      Write out line from first input file
      End If
      Loop

      Close all files

      -----
      Tim Patrick
      Start-to-Finish Visual Basic 2005
      hey all,
      i have 2 notepad files and i want to replace every 3rd line in 1 of
      the
      notepad files with the exact same line in the other notepad file.
      what's the
      easiest way to do this?
      thanks,
      rodchar

      Comment

      • rodchar

        #4
        Re: line replacing ideas

        thanks for the tips everyone.

        "Tim Patrick" wrote:
        Here's some pseudocode that may meet your needs.
        >
        Dim position As Integer = 0
        >
        Open the first file
        Open the second file
        Open the output file
        >
        While (both input files still have data)
        Read in one line from both input files
        >
        position += 1
        If ((position Mod 3) = 0) Then
        Write out line from second input file
        Else
        Write out line from first input file
        End If
        Loop
        >
        Close all files
        >
        -----
        Tim Patrick
        Start-to-Finish Visual Basic 2005
        >
        hey all,
        i have 2 notepad files and i want to replace every 3rd line in 1 of
        the
        notepad files with the exact same line in the other notepad file.
        what's the
        easiest way to do this?
        thanks,
        rodchar
        >
        >
        >

        Comment

        Working...