Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6728727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:12:17+00:00 2026-05-26T10:12:17+00:00

In VB6, I’m looking for a way to remove a line of text from

  • 0

In VB6, I’m looking for a way to remove a line of text from a text file if that line contains some string. I work mostly with C# and I’m at a loss here. With .NET there are several ways to do this, but I’m the lucky one who has to maintain some old VB code.

Is there a way to do this?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:12:17+00:00Added an answer on May 26, 2026 at 10:12 am

    Assuming you have the filename in a variable sFileName:

    Dim iFile as Integer
    Dim sLine as String, sNewText as string
    
    iFile = FreeFile
    
    Open sFileName For Input As #iFile
    Do While Not EOF(iFile)
      Line Input #iFile, sLine
      If sLine Like "*foo*" Then
        ' skip the line
      Else
        sNewText = sNewText & sLine & vbCrLf
      End If
    Loop
    Close
    
    iFile = FreeFile
    Open sFileName For Output As #iFile
    Print #iFile, sNewText
    Close
    

    You may want to output to a different file instead of overwriting the source file, but hopefully this gets you closer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a VB6 program that does some string processing in a loop (approximately
Using VB6, how do I copy a file from another computer to my computer
Using VB6 In a folder, am having n number of text files, file names
Using VB6 I have the text file with different sizes, so i want to
In VB6, I was told that when testing for an empty string, it would
Using VB6 Code. Dim posn As Integer, i As Integer Dim fName As String
Using VB6 and Access 2003 Query Select Temp.* into NewTable from Temp Table Name
Using VB6 Code. CommonDialog1.DialogTitle = Open File CommonDialog1.Filter = *.* CommonDialog1.FilterIndex = 1 CommonDialog1.Flags
In VB6 I created a form with some textboxes, listboxes, and command buttons on
VB6 & SQL Server 2005 When i run the Windows based Software exe file,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.