There are three ways you can add intelligence to an InfoPath 2007 form. You can attach conditional rules directly to data elements, you can write script that gets embedded into the form, and you can write managed code that is called from a separate "code behind" assembly. In addition to these choices, there are two ways that you can write managed code. You can install Visual Studio Tools for Applications (VSTA) and launch the development environment from within InfoPath, or you can install Visual Studio Tools for Office (VSTO) and launch InfoPath from within the Visual Studio 2005 IDE. The project structure is the same in both cases, but with VSTO you have more control over the client application. For instance, you cannot write code that modifies the InfoPath 2007 user interface from within a VSTA project. For that, you have to use VSTO.
To start adding code to a form, you must first select the appropriate options in the form itself. Open the form options dialog by choosing Form Options from the Tools menu in InfoPath 2007, and then select the Programming category from the list on the left side. In the Programming Language section, you can choose the form template code language from a dropdown list. Selecting JScript or VBScript causes InfoPath to launch the Microsoft Script Editor when you add an event handler to your form. Selecting C# or Visual Basic launches VSTA. If VSTA is not installed, then these options do not appear in the list.