943,822 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 11972
  • VB.NET RSS
Jul 17th, 2008
0

Delete From String array

Expand Post »
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.
VB.NET Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
ruchika beddy is offline Offline
35 posts
since Apr 2008
Jul 17th, 2008
0

Re: Delete From String array

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
Reputation Points: 3
Solved Threads: 1
Junior Poster in Training
KillerOfDN is offline Offline
51 posts
since Apr 2008
Jul 19th, 2008
0

Re: Delete From String array

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.
Reputation Points: 3
Solved Threads: 1
Junior Poster in Training
KillerOfDN is offline Offline
51 posts
since Apr 2008
Jul 20th, 2008
0

Re: Delete From String array

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
ruchika beddy is offline Offline
35 posts
since Apr 2008
Jul 20th, 2008
0

Re: Delete From String array

Might you try utilizing the mid left and right functions? Hope this helps,
Bill P.
Reputation Points: 10
Solved Threads: 1
Light Poster
Bill Purkins is offline Offline
42 posts
since Jul 2008
Jul 21st, 2008
0

Re: Delete From String array

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:

VB Syntax (Toggle Plain Text)
  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.
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006
Jul 24th, 2008
0

Re: Delete From String array

Hi,
Is your problem solved?
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Life and Death
Next Thread in VB.NET Forum Timeline: Is this correct





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC