|
-
May 25th, 2013, 05:34 AM
#1
Thread Starter
Hyperactive Member
[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
-
May 25th, 2013, 05:54 AM
#2
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
-
May 25th, 2013, 05:58 AM
#3
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.
-
May 25th, 2013, 06:37 AM
#4
Thread Starter
Hyperactive Member
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
|