I have put Form1.vb and Form1.Designer.vb for a small serial port program in our knowledgebase, but it seems that these two files are not enough.
In some examples I have seen Form1.Designer.vb inserted in the beginning of Form1.vb to form a complete source code. How do you do that

How many source files are needed to publish a VB program
nbl
This is the project settings and resources, available to all forms. It also contains things like what form to start up first.
You might store some general messages, connection strings in the project settings instead of a individual form or class.
pfdeveloper
The partial classes helps to separate the code needed to create the form controls and layout from the events you add to the controls. It is a good thing as it helps keep the designer generated code separated from the code you add. In VB 2005 you normally never see this unless you choose to show all files (its a button on the solution explorer). I would guess that microsoft choose to show a form as only one file in the solution explorer to be more like old VB6 IDE.
The project knows what files are depending on other files. If you open your projects vbproj file in notepad or similar you can see something like this
<Compile Include="Form1.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.vb">
<DependentUpon>Form1.vb</DependentUpon>
<SubType>Form</SubType>
</Compile>
<EmbeddedResource Include="Form1.resx">
<SubType>Designer</SubType>
<DependentUpon>Form1.vb</DependentUpon>
</EmbeddedResource>
This information is used so compiling is done on a partial class as it would be a single file. For very large classes (that you normally should avoid creating) it can really help to have it separated in multiple files. For instance 2 developers can work on it at the same time.
These partial classes does not help to make it easier to distribute a simple example source as you noticed.
You will be amazed how creative some are in using small demonstration programs.
VinnieThaMadeMan
If you exclude bin and obj folders you get what you should distribute to have a complete compilable project.
If you just want to demonstrate some code it might be an idea to put it into a class and just distribute that.
The files for forms should only contain visualisation logic and not the application code. Separating this allows for better sharing of common code. If you would have separated the code that is for serial communication into a separate class I would have been able to reuse it by adding it to a VB.NET class library, compile and consume it from a C# frontend.
danillo ciafrei
That was in previous version of Visual Studio 2005.
In VS 2005 the designer form create two files (both are a same class, but in two files, this is a partial class, new concept in this version of visual studio 2005).
Tim McDaniel
It seems like you need to publish:
Form1.vb ' The source code
Form1.Designer.vb ' Object parameters
Form1.resx
Projectname.vbproj ' Project definition
My Project folder
Bin folder ' Not sure if needed
Obj folder ' Not sure if needed
Quite a number of files and folders to exchange a simple source code. To me it seems that Form1.vb and Form1.Designer.vb contain all the information, which is needed, but if for example the My Project folder is not included you cannot open the project.
I really think that a description of the file structure is needed. I have not been able to find such a description anywhere. I hate this not-need-to-know philosophy.
Tatakau
Thanks for the answer. I will try to get a little more knowledge about how projects are build.
I still find it a little difficult to see that Form1.vb and Form1.Designer.vb can be separated. If this is done, a lot of the names in Form1.vb are just grapped out of the air, since the object definitions are done in Form1.Designer.vb. At least you have to find very describing names to understand a source code without access to the definitions. To me there is really not much difference between a declaration of a string or an array or the declaration of more complicated objects, so why include strings and arrays in Form1.vb and other objects in Form1.Designer.vb I can see that it is not recommended to edit Form1.Designer.vb by hand, but statements, which must not be touched by hand, could just be read-only and written in another color.
Of course I could have made the whole serial communication example as a class (when I learn how to do it :-) ), but I presume that very few are interested in including this in any program as it is. It needs to be modified for the actual application. The program is just intended as a getting-started project to show how to transmit and receive from the serial port, so the source code is much more important than the program itself.
Tran Van Thang
Thanks for the information.
It is logical that Form1.vb, Form1.Designer.vb, Form1.resx and ProjectName.vbproj is needed, but why the folder My Project I can see that if it is not present you get a compile error, but what is in this folder, which has not already been defined by Form1.vb and Form1.Designer.vb