Hi again!
So I am expanding my program, but can't get the logic right behind my code. The code itself is no problem.
I have a listbox with items (text files) and every file needs to be read by string. If a string contains a word, it needs to place that word into a group of textboxes. For every different word you need a different textbox (same words into different files can occur). Also there is a counter for how many times that word is found into the files that have been checked.
The reason why I place it in textboxes, is because you need to type a code (123,456,789) into the textbox right of it, and this will be put into a new line into the textfile underneath the line that corresponds with the ABC, DEF, GHI (for example).
So the logic in words:
For every file that has been checked into the checkedlistbox, read every line. If a line starts with "AAA" then place a specific word into that line (that word is between brackets; ABC or DEF as example) into the first empty textbox. For every same word found, a label gets a value of +1. Then is all the files are processed, you type in a corresponing text next to the filled textbox. Then with a new buttonclick, read every line, and if a line starts with AAA AND! ABC,DEF or... put a new line underneath, with contains 123,456,789,... (the corresponding code you filled in).
Layout of a pup-up where you type in the code (just to have a visual thought):
![]()
My code so far (reading the line and placing the word into textboxes, the putting a new line part is a different button and should work):
The problem now is, to fill in a new textbox if a new word occurs, or if one of the previous textboxes already contains that words (AAA) do a +1 on the corresponding label :)
Thanks a lot!!!
So I am expanding my program, but can't get the logic right behind my code. The code itself is no problem.
I have a listbox with items (text files) and every file needs to be read by string. If a string contains a word, it needs to place that word into a group of textboxes. For every different word you need a different textbox (same words into different files can occur). Also there is a counter for how many times that word is found into the files that have been checked.
The reason why I place it in textboxes, is because you need to type a code (123,456,789) into the textbox right of it, and this will be put into a new line into the textfile underneath the line that corresponds with the ABC, DEF, GHI (for example).
So the logic in words:
For every file that has been checked into the checkedlistbox, read every line. If a line starts with "AAA" then place a specific word into that line (that word is between brackets; ABC or DEF as example) into the first empty textbox. For every same word found, a label gets a value of +1. Then is all the files are processed, you type in a corresponing text next to the filled textbox. Then with a new buttonclick, read every line, and if a line starts with AAA AND! ABC,DEF or... put a new line underneath, with contains 123,456,789,... (the corresponding code you filled in).
Layout of a pup-up where you type in the code (just to have a visual thought):

My code so far (reading the line and placing the word into textboxes, the putting a new line part is a different button and should work):
Code:
'reading the file of each item that has been checked:
For Each item In CheckedListBox1.CheckedItems
Dim streamReader As New System.IO.StreamReader("C:\Salvagnini\syscon\S4_1387\production\" & tbmapnaam.Text & "\" & CheckedListBox1.GetItemText(item))
TextBox2.Text = My.Computer.FileSystem.ReadAllText("C:\Salvagnini\syscon\S4_1387\production\" & tbmapnaam.Text & "\" & CheckedListBox1.GetItemText(item))
'reading line by line
Do Until streamReader.EndOfStream
Dim line As String = streamReader.ReadLine()
Dim linetrim As String
Dim bestandsnaam As String = CheckedListBox1.GetItemText(item)
If line.StartsWith("AAA") Then
Dim strWords() As String = line.Trim.Split(" "c)
linetrim = strWords(1)
insert.tb1.Text = strWords(1)
insert.tb1.Text = insert.tb1.Text.Replace(Chr(34), "")
insert.tb1.Text = insert.tbzwee.Text.Replace(".txt", "")
'counting the words
If line.Contains(insert.tb1.Text) Then
insert.Label2.Text = insert.Label2.Text + 1
If insert.Label2.Text > 100 Then
insert.Label2.BackColor = Color.Red
Else
insert.Label2.BackColor = Color.LightGreen
End If
End If
End If
Loop
Next
Thanks a lot!!!