Solved

delete a row in a file

Posted on 2004-09-26
6
192 Views
Last Modified: 2010-04-23
I have a string like 2004-10-21 and the file looks like this

1999-01-01
2004-10-01
2004-09-30
2004-10-21

and i wan't to delete 2004-10-21 but leav the other dates intact how?
0
Comment
Question by:stromberg10
6 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 43 total points
ID: 12155988
You have to read file and write it to different file, When you found the string that you want to delete, don't write it. WHen you finished, delete the original file and rename the new one.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 41 total points
ID: 12157004
Do you know how to read text files?  Is it possible to have multiple dates the same.  You could read the entire contents of the file into a string, replace the string with nothing, and then write the string back to the file.

Bob
0
 
LVL 10

Assisted Solution

by:123654789987
123654789987 earned 41 total points
ID: 12159293
try this. This is the code to remove the third string - 2004-09-30


                                                 str1 as string
                  str2 as string

                  str1 = "1999-01-01     2004-10-01    2004-09-30  2004-10-21"

            
                  length as int
                  fourthString as int

                  length = str1.Length()
                  fourthString = str1.IndexOf("2004-10-21")

                  str2 = str1.Remove(fourthString , length-fourthString) // This gives the final output string

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

17 Experts available now in Live!

Get 1:1 Help Now