| | |
Delete From String array
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 35
Reputation:
Solved Threads: 0
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)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim RowNum As ListViewItem For Each RowNum In ListView2.SelectedItems ListView2.Items.Remove(RowNum) Next Dim arrlines() As String = IO.File.ReadAllLines("c:\Records.txt") End sub
Last edited by Tekmaven; Jul 18th, 2008 at 6:28 am. Reason: Code tags
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:
I am sure that there are better ways to do this. But it just works!
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)
... Dim c As Integer = 0 Dim valueToDelete As String = "some string" Dim arrLinesTemp() As String Dim arrLines() As String = IO.File.ReadAllLines("c:\Records.txt") ' Make a copy of the original array avoiding the value ' you want to delete For x As Integer = 0 To UBound(arrLines) If arrLines(x) <> valueToDelete Then arrLinesTemp(c) = arrLines(x) c += 1 End If Next x ' Clear the original array Array.Clear(arrLines, 0, UBound(arrLines)) ' Restore the values left in the original array Array.Copy(arrLinesTemp, arrLines, UBound(arrLinesTemp)) ...
Last edited by dmf1978; Jul 21st, 2008 at 12:22 am.
-- Martín
![]() |
Similar Threads
- delete array and assigns array to pointer (C++)
- Help with delete blank from string function PLEASE!!!! (C)
- Creating a Basic String Database (C++)
- c++ or shell script to delete some files (C++)
- How do I delete an instance of an Array? (C++)
- works for static need help to make it dynamic (C++)
- Array limit (C)
Other Threads in the VB.NET Forum
- Previous Thread: Life and Death
- Next Thread: Is this correct
| Thread Tools | Search this Thread |
.net 30minutes 2005 2008 access account arithmetic array arrays basic binary bing button buttons c# center check checkbox code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save searchbox searchvb.net select serial server soap sorting table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





