I was writing a book which I'm considering publishing in the future, but I realized that there was some code I wanted to include that might be an issue. I wrote it with a student license, so would including it in a book technically be commercial use? The defense I think of with this is that in that case, would you not be allowed to use or show anything from any program for which you don't have a commercial license for?
I assume the point is that you were using some text editor that you acquired under a student license, and you wrote part of the code as a student using that editor. So the issue might be that the editor cannot be "used for commercial purposes". You would have to look at the wording of the license, so for example the MS Word Student license says that "The software may not be used for commercial, non-profit, or revenue-generating activities". This does not preclude exploiting a non-revenue generating product made with Word, for example a piece of code that you created for educational purposes, it simply precludes using that version of Word to make a buck. On the other hand, if you set out to write a bunch of code for money, and were using the student version of Word, then you were using the product a commercial purpose. You can use a different editor with different licensing conditions (e.g. no such restrictions), rewrite the code or other text and be in conformity with the license. Regardless of the license terms, the intellectual property is your property.
The question is impossible to answer completely without knowing the exact license of your software development tools.
However, it would be unusual that you are not the complete owner of the source code that you have written yourself. Just like the maker of a word processor has no rights to the text that you are writing with it. Exceptions might be code that has boilerplate code added to it by the tools that you are using.
But what you really need to do is read the license of your development tools carefully, and when in doubt consult a lawyer.