Hi guys,
I have spent a morning working on this. Not sure if I will ever get it right.
What I want to do is read a text file and based on list of constant values split the original file in two smaleer files.
One of them to contain only the rows from original file, and the other one to contain only the rows from original file that don`t match the values from the lsit.
So If I have File A and list of criteria (1,2,3,4,5- known number)
in output I should have file a.txt that will have rows from file A that match the 1,2,3,4,5 . and file b.txt that will have no matching values to the criteria 1,2,3,4.
In every row the criteria string in File A will be positioned at the same position.
I have this code so far:
Dim st As String = Mid(RichTextBox1.Text, 96, 8)
Dim strrow As String = RichTextBox1.Text.Remove(800)
Dim 1 As String
Dim 2 As String
If st = ("1" Or "2") Then
Dim sw2 As New FileStream("C:\Test\part1.txt", FileMode.Create, FileAccess.Write)
Dim ss As New StreamWriter(sw2)
ss.WriteLine(strrow)
Else
Dim sw1 As New FileStream("C:\Test\part2.txt", FileMode.Create, FileAccess.Write)
Dim ss As New StreamWriter(sw1)
ss.WriteLine(strrow)
ss.Close()
End If
it throws error when i run it it says cannot convert double to string.
I don`t understand why . Also I need to loop through every row in the file in every row starting fro 96 characte to 104 i will have to check if that vaue matches 1,2,3 ... or not , based on that to split the original file in two files.
Would I bind values of criteria to an array. That I can do but then I have no idea what the syntax might be.
Thanks in advance for your help.