Solved

VB files

Posted on 1998-12-30
1
118 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 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