Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB files

Posted on 1998-12-30
1
116 Views
Last Modified: 2010-05-03
please write two functions that add\remove a line from file
the line is selected in a list box, and the function search this line in the text file and add\remove it.
0
Comment
Question by:amirdagan
1 Comment
 
LVL 18

Accepted Solution

by:
deighton earned 50 total points
ID: 1453265
Private Function RemoveLine(sFilePath As String, sLine_to_delete As String)

    Dim iFile1 As Integer
    Dim iFile2 As Integer
   
    Dim sTemp As String
   
    iFile1 = FreeFile
    Open sFilePath For Input As #iFile1
   
    iFile2 = FreeFile
    Open "c:\temp123z.ajd" For Output As #iFile2
   
    While Not EOF(iFile1)
   
        Line Input #iFile1, sTemp
       
        If sTemp <> sLine_to_delete Then
       
            Print #iFile2, sTemp
           
        End If
       
    Wend
   
    Close iFile1, iFile2
   
    Kill sFilePath
    FileCopy "c:\temp123z.ajd", sFilePath
    Kill "c:\temp123z.ajd"
   
End Function


Private Function AddLine(sFilePath As String, sLine_to_add As String)

    Dim iFile1 As Integer
   
    iFile1 = FreeFile
    Open sFilePath For Append As #iFile1
   
    Print #iFile1, sLine_to_add
   
    Close iFile1
   
   
End Function


0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question