| | |
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 .net2008 2008 access advanced application array basic beginner browser button buttons center checkbox click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function generatetags html images input intel internet listview map mobile module monitor msaccess net number objects open panel pdf picturebox picturebox2 port position print printing read regex remove right-to-left save search searchvb.net serial settings shutdown socket sorting sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol validation vb vb.net vba vbnet visual visualbasic visualbasic.net visualstudio.net web winforms winsock wpf wrapingcode xml year





