There are programmers out there who program solely for themselves. They write code/applications and no one but them ever sees their applications. However, most of you are like me and we want to revel in the accolades that our friends and peers heap on us when we provide them with exactly the right program to meet a need that they have expressed! Ah.. But how do you give them the program? One of VB's weakest features has always been it's ability to create an installation program that allows you to distribute your great application to your users. This section introduces the distribution aspect of programming.
If you want to run your VB program, you have two options. You can open the VB project within the VB IDE and run it there. Or, you can compile the project into a .EXE file and run that.
To give (or sell) your program to other people takes more effort. You cannot give them a copy of VB6 (it's illegal). If they already have VB6 (or the same version as you have), then you can simply give them the .EXE file and they can run the .EXE file just fine.
Usually, however, you cannot depend on your users having a copy of VB on their machines. That being the case, you not only have to give them a copy of the .EXE file, but also a copy of any VB required files which they don't have on their machine. Microsoft allows you to distribute any such files as are required by the user to run your distributed .EXE program. Note that the distributed files can only be used in the run time program. Adding a distribution will not necessarily allow a user who has VB on his PC to use those files (OCXs) in the IDE. More on that later.
The fact that a VB program requires the presence of other files to operate correctly is really bad news because those extra files can be very large. As a worst case example, I've written a VB VRML application called WinPlace whose distribution file measures almost 10MB! That's a lot of diskettes, or else a lot of download time over a modem. Many potential users of WinPlace won't try it simply because it will take too long to download the installation files!
Every VB program requires the use of a 1.4MB file, msvbvm60.dll. That means that no matter how small the .EXE file is that you create, that your minimum size for distribution files is 1.4M. Often, a VB .EXE file is only a few hundred KBytes (100K - 400K), but at those sizes you're automatically going to require at least two distribution diskettes.
Another "gotcha" that awaits within VB is that the addition of a single feature can cause an easy multi-megabyte increase in the size of your distribution files. For example, add in any database features to a VB program and you'll see the distribution file list go way up!. It's hard to tell ahead of time how big your distribution file size is, so you pretty much have to create the distribution files to know for sure.
In this section of the tutorial I'm not going to walk through an actual setup file creation. The capability in VB is known as the "Package and Deployment Wizard" and it's reasonably straightfoward to use, although you have very little control over the details of the installation procedure.
Third Party Help
I use the Package and Deployment Wizard for some of my applications, but I also use the InstallShield software as well as the Wise Installation System. The latter two are shrink-wrap programs which are generally much more powerful than the built-in capabilities of VB. However, these also each cost several hundred pounds. For your applications which mostly go to friends, or to a limited set of users, don't hesitate to use the built-in VB Packaging and Deployment Wizard. If you want a wider range of options on how to control the installation process, check out one of the two above.