OK, I figured out a simple way to solve this:
Visual Studio 2012 has an XSD Schema to Serialization coding tool.
In Infopath, save your form as source (from the file menu).
Then go to Start --> Visual Studio --> Visual Studio Tools --> Developer Command Prompt. Navigate to the directory you saved your infpath source and type:
xsd myschema.xsd /classes
I also added
/language:VB
afterwards to get VB code. It will save the code to the same folder in the correct format. So much easier than writing it myself.