[RESOLVED] Writing to multiple .txt files
Hey Guys,
What i'm trying to do is write to individual .txt files depending if a string is found from items in a listbox.
code:
Code:
For Each itm As String In listBoxMain.Items
'// PLATFORM #1
If (itm.Contains("string1") Or itm.Contains("string2")) Then
Using SW As New StreamWriter("save\" & "Strings12.txt", True)
SW.WriteLine("Found - " & itm)
End Using
ElseIf (itm.Contains("string3")) Then
Using SW As New StreamWriter("save\" & "Strings3.txt", True)
SW.WriteLine("Found - " & itm)
End Using
End If
Next
So far only the first .txt file is being saved, my logic must be skewed lol
any help would be appreciated :)
cheers guys
Graham
Re: Writing to multiple .txt files
Hi,
I may not have written this the same way myself, but as it stands, your code works fine so the question to ask is what is the information contained in your ListBox?
One thing you may need to consider is that the Contains Method of the ListBox is Case sensitive so this may be the first thing that you need to compensate for.
Hope that helps.
Cheers,
Ian
Re: Writing to multiple .txt files
Have you debugged that code? When you get to the ElseIf line, what is the value of 'itm' and what is "string3"? Presumably no item actually contains that String. The Contains method is case-sensitive, so maybe that could be the issue.
Re: Writing to multiple .txt files
Hey Guys,
Ohhhh , i never knew that lol that was it J the one time i put everything in lowercase :) it was because the string should have been Capitalized "News" and i had "news" :)
thanks a lot guys :)
Graham