how to force VB to strickly execute code line-by-line
I'm writting a program for sorting and editing (large) text files containing lists of random words. During the process, i've used a text field that informs the user in which stage the process is. The code is something like this (i won't paste the actual code because it's not necessary and it's hard to read) when the user presses the button to start the process:
print "Opening file..." in textfield
open .txt file for input
print "file opened successfully" in textfield
print "reading records..." in textfield
Do While loop to save .txt records into an array
print "Sorting..." in textfield
save current time
run QuickSort3 module to sort the array
save current time
print the DateDiff in textfield
The problem here is that VB is getting ahead of the commands so when I press the button to begin the above process, the program freezes for few seconds (which means it is running the sorting algorithm) and then prints everything in the textfield at once. Even the two "save current time" are saving the exact same time no matter how long it took for the sorting algorithm to do it's job.
I have tried to use "DoEvents" in many places in the code with no luck. So, how can I force VB to execute the code line-by-line? I want to see the text in the textfield before the program starts sorting the array!
wow...that was weird! I tried to refresh the textbox just before the sorting function and it didn't seem to fix the problem. I started replying here telling that it didn't work when I thought to add one more textbox.refresh right before saving the .txt records to the array and voila!
It turns out, it takes much more time to read a (213.000 records) .txt and store it into an array than making like a gazillion loops to sort it. I just wrote these so othens can know!