The Sample Programs

The sample programs, contained on the accompanying CD, are completely stripped-down programs that illustrate solely the points being made in this chapter and consequently appear contrived. Because these programs have limited functionality and were never intended for real-world use, they don’t contain any error handling. Error handling has been omitted to keep the listings short and uncluttered.

Program 1 (SAMPLE1.MAK) consists of a text box for user input, shown in Figure 6-4, and a button to bring up a screen to gather more information about that entry. This information is stored in an INI file. The information recorded by this program is considered relevant to the work of the current workstation’s normal user.

Figure 6-4 A sample user-details dialog box produced by SAMPLE1.MAK

Program 2 (SAMPLE2.MAK) gathers the same information as Program 1 but for other people. It stores the information in an access database, shown in Figure 6-5. The information, along with the name of the user who captured it, can be printed out in a Word document.

Program 3 (SAMPLE3.MAK) demonstrates using an out-of-process ActiveX server in a Visual Basic 3 program, and AddressServer (AddressServer.Vbp) is the Visual Basic 5 out-of-process ActiveX server used in this example.

Data.mdb is the database file used by these programs, and its location should be set in the file SAMPLE.INI, which should be placed in the Windows directory.

The SAMPLE1.MAK and SAMPLE2.MAK programs share a common form—frmAddress—and some common subroutines and constants contained in Common.Bas. The frmAddress form uses an API call to ensure that users type in only five-line addresses.

SAMPLE1.MAK comprises frmUser.frm, Common.Bas, and frmAddre.Frm. SAMPLE2.MAK comprises frmName.frm, Common.Bas, and frmAddre.Frm.

Other changes made to the code to gradually move all systems to Visual Basic 5 in a controlled manner are illustrated throughout this chapter.

The other sample included is a program named SETTINGS.VBP (in the 16BitServer directory), which is a simple 16-bit ActiveX server that can be called from Visual Basic 5 to read and write to INI files. This illustrates two points—first, 16-bit Visual Basic 4 can be used as a way of thunking 16-bit APIs into 32-bit programs; and second, SETTINGS.VBP stands as an illustration of the “Where has my INI file data gone?” problem.

Figure 6-5 A sample address form produced by SAMPLE2.MAK