This is a synchronous process. The computer can only do one thing at a time. What happens is while you're busy looping over all of the values in the file, you're keeping the main thread busy, which means it's not able to respond to resizes, clicks, user input, etc. Your best bet for maintaining responsiveness is going to be to offload the filtering duties to a worker thread. However, you have worse problems: your filtering logic does nothing at all close to what it should do.
To filter, you will be asking the question, "Does this word start with these letters?" for each word in the list. Instead, here is what your code does:
Code:
For 1 to the number of letters in the search box
If the next letter is not a space or comma
add the next character to tempResult
increment counter_search
End If
Next
This block will leave you with the first
letter letters in dictionary.txt; the string will possibly contain a line break but your file might be entirely comma-delimited. Assuming a search value of "ac", if the file starts with "apple" you're going to store "ap" in
tempResult. Needless to say, when you get to the next loop, it's very unlikely that an item that matches will be found and you get nothing. This is why the form goes white; you are telling the computer the wrong thing to do.
It'd be much better to first get a list of words from the file, then go over this list of words. You'll still need some asynchronous processing to make it work without appearing to lock up. I say get the filtering working first. It'll be much easier if you define a GetWord() method that can pull the next word from the stream. It sounds fun to implement as an example, but I don't really have time today.
Nitpicker's Corner
Code:
Using sr As New StreamReader("Dictionary.txt")
...
End Using
sr.Close()
This is wrong, and shouldn't compile unless you are making a different mistake. The Using statement closes the stream for you, and also limits the scope of the variable
sr to its own block. Remove the
Close call.