Stuck with program flow and freezing programm

I would need to post some code exceeding the allowed 9500 characters.

Use the Additional Options... link to attach the code.