|
-
Apr 28th, 2003, 10:10 AM
#1
Thread Starter
Addicted Member
Deleting a string from a textfile
Hello,
the scenario is...
I have a listbox which is populated from a textfile. When the user double clicks an item in the listbox the value is put in a textbox to indicate that this is the value to delete from the list.
Does anyone have a snippit of code which looks for the value in the an array and delets it if found, then rewrites the array to the textfile?
Any help really appreciated.
-
Apr 28th, 2003, 10:12 AM
#2
Fanatic Member
I'd use the Replace() function
replace the string, then save the array to text file
-
Apr 28th, 2003, 10:18 AM
#3
Stuck in the 80s
Re: Deleting a string from a textfile
Originally posted by HELPmyVB
Does anyone have a snippit of code which looks for the value in the an array and delets it if found, then rewrites the array to the textfile?
What array? The ListBox.List array?
If so:
VB Code:
List1.RemoveItem List1.Selected
(off the top of my head, I can't check right now, but that should be close)
-
Apr 28th, 2003, 10:19 AM
#4
Stuck in the 80s
Then, to rewrite it to the text file, would depend on the format you have it in there. If it's just:
Item
Item
Item
Item
Item
Then:
VB Code:
Dim i As Integer, iFF As Integer
iFF = FreeFile
Open "C:\yourfile.txt" For Output As #iFF
For i = 0 To List1.ListCount
Print #iFF, List1.List(i)
Next
Close #iFF
-
Apr 28th, 2003, 10:26 AM
#5
PowerPoster
Re: Deleting a string from a textfile
Originally posted by HELPmyVB
Hello,
the scenario is...
I have a listbox which is populated from a textfile. When the user double clicks an item in the listbox the value is put in a textbox to indicate that this is the value to delete from the list.
Does anyone have a snippit of code which looks for the value in the an array and delets it if found, then rewrites the array to the textfile?
Any help really appreciated.
not sure i understand the question, but this will delete a searchstring from an array
VB Code:
arrOne = split(replace(join(arrTwo,vbcrlf),vbcrlf & strSearch & vbcrlf ,vbcrlf),vbcrlf)
untestested, but should give you the idea
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|