Solved

VB files

Posted on 1998-12-30
1
113 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now