This question already has an answer here:
I am a citizen of the United States but next year I am going on exchange in Spain. My student visa will expire in the end of June but I want to travel around to visit friends and family I have in other countries within the Schengen Zone (ex. Denmark, Norway, Germany etc). I have tried reading other forums and questions with nearly the same type of question, but I still don't understand the answer. I know that under normal circumstances I can enter the Schengen Zone without a visa and travel within it for 90 days as a tourist. So after my visa expires, let's say I leave and go to Germany. Would that be okay or not? Because I didn't enter Spain/the Schengen Zone as a tourist until I leave Spain as a student. Is that logic correct?