Delete From String array

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 35
Reputation: ruchika beddy is an unknown quantity at this point 
Solved Threads: 0
ruchika beddy ruchika beddy is offline Offline
Light Poster

Delete From String array

 
0
  #1
Jul 17th, 2008
I know How to Delete a Textfile , I even know how to write the temp string data into a TextFile. But i do noy know how to delete from String array,into which i read all the data of the file. Mine Code is as under,Plz help me out. I will ber very thankful to U.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim RowNum As ListViewItem
  3.  
  4. For Each RowNum In ListView2.SelectedItems
  5. ListView2.Items.Remove(RowNum)
  6. Next
  7.  
  8.  
  9. Dim arrlines() As String = IO.File.ReadAllLines("c:\Records.txt")
  10.  
  11. End sub
Last edited by Tekmaven; Jul 18th, 2008 at 6:28 am. Reason: Code tags
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 50
Reputation: KillerOfDN has a little shameless behaviour in the past 
Solved Threads: 1
KillerOfDN KillerOfDN is offline Offline
Junior Poster in Training

Re: Delete From String array

 
0
  #2
Jul 17th, 2008
If you only want to delete some records from the file, consider loading them into your ListView, removing the listview items you don't need, then write the listview data back to the file...

Hope this helps
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 50
Reputation: KillerOfDN has a little shameless behaviour in the past 
Solved Threads: 1
KillerOfDN KillerOfDN is offline Offline
Junior Poster in Training

Re: Delete From String array

 
0
  #3
Jul 19th, 2008
Did you find the solution? If so can you please close this thread by marking it as Solved. And please leave a post with your fix as this will help other forum users.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 35
Reputation: ruchika beddy is an unknown quantity at this point 
Solved Threads: 0
ruchika beddy ruchika beddy is offline Offline
Light Poster

Re: Delete From String array

 
0
  #4
Jul 20th, 2008
I do not delete from String Array,To do wat i wanted....I use the another method..I still do not know how to delete from string array.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 42
Reputation: Bill Purkins is an unknown quantity at this point 
Solved Threads: 1
Bill Purkins Bill Purkins is offline Offline
Light Poster

Re: Delete From String array

 
0
  #5
Jul 20th, 2008
Might you try utilizing the mid left and right functions? Hope this helps,
Bill P.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: Delete From String array

 
0
  #6
Jul 21st, 2008
Hi,

I see you have the contents of the text file in the array arrlines.
Then, guess that you have the value you want to delete in the valueToDel variable:

  1. ...
  2. Dim c As Integer = 0
  3. Dim valueToDelete As String = "some string"
  4. Dim arrLinesTemp() As String
  5. Dim arrLines() As String = IO.File.ReadAllLines("c:\Records.txt")
  6.  
  7. ' Make a copy of the original array avoiding the value
  8. ' you want to delete
  9. For x As Integer = 0 To UBound(arrLines)
  10. If arrLines(x) <> valueToDelete Then
  11. arrLinesTemp(c) = arrLines(x)
  12. c += 1
  13. End If
  14. Next x
  15.  
  16. ' Clear the original array
  17. Array.Clear(arrLines, 0, UBound(arrLines))
  18.  
  19. ' Restore the values left in the original array
  20. Array.Copy(arrLinesTemp, arrLines, UBound(arrLinesTemp))
  21. ...
I am sure that there are better ways to do this. But it just works!
Last edited by dmf1978; Jul 21st, 2008 at 12:22 am.
-- Martín
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: Delete From String array

 
0
  #7
Jul 24th, 2008
Hi,
Is your problem solved?
-- Martín
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC