| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual Basic |
| Version: | 1.1 |
| Released: | March 20, 2001 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control ActiveX with Visual Basic |
| Download code: | quote_generator.zip |
This is a series of sample programs which show how to use TX Text Control in office applications. The main task of an office application typically is to create documents from information taken from a set of databases. For instance, a quote is generated from a record in an address database and one or more records in an article database.
The sample programs are built up in several steps, starting very simple with only a single address database in Step 1, and adding more features later on.
Step 1: When the program is started, it displays an address database in a data bound grid control. This may not be the most scalable approach, but all we need in this first version is a simple way to select a record from the database, and therefore using a grid and a data control will do for now.

Selecting the File/New Quote menu item takes the current record from the database and creates a document from it. This is done in 2 steps:
A form containing a TX Text Control is opened, and a stylesheet is loaded. A stylesheet is a file that serves as a template for the final document. It contains all text parts which are equal to all documents, for instance a phrase like "In reply to your inquiry and according to our general terms of business we are pleased to..", and placeholders for information that is to be inserted from a database, like 'Address', 'Date', and so forth. It also defines the font, font size, company logo, and layout, so that all files will have the same look.

Once the stylesheet has been loaded, the placeholders are updated from the database, so that they now contain the real address, name, customer number, and date.

The stylesheet can be edited with the Advanced menu. Later versions of the program will have additional stylesheets for other types of documents.
Business applications tend to become very large over time, and often, as the company grows and changes, need to be extended in unexpected ways. Often early versions of the program use a simple desktop database, and later need to be adapted to a more powerful client/server model. Or the company suddenly has a dependancy in another country, and the software has to deal with different languages and currencies. For this reason, a modular, component based design is vital, and we will already follow this approach in the first step.
The application can be divided into several logical units:
Note that Step 1 only contains modules 1 and 4. The remaining ones, together with an additional article database, will follow in Step 2.
This is part 2 of our series about creating a quote generator with TX Text Control. (Part 1 is online). The system requirements again are Visual Basic 6 and a full or trial version of TX Text Control 7.
Before you read everything about how it is programmed, you may want to run it and see what it does, so here is a short user's guide first.
The first thing we need to do in order to add article descriptions and pricing to our quotes from Step 1 is to add another database. We call it the article database, and display it on the main form beside the address database.

That's it for the main form. In the Editor module, we now add a menu item which lets us insert items from the article data into a quote.
A list of articles is best displayed in a table, and TX Text Control offers all required table functions to let us insert product IDs, descriptions, and prices into the respective cells, as well as to perform calculations. We therefore add a table to the style sheet and adjust its column widths, text distances, and caption text so that later only the plain text needs to be filled in.
This is what the style sheet now looks like:

A new menu item has been added to the Advanced menu, which allows to insert a table. Also, a Format/Table menu item has been created which calls TX Text Control's Table Attribute dialog box, so that we can adjust the table grid lines and background shading. The table's column widths and tabs are adjusted in the ruler bar. Note that the 2 rightmost columns have decimal tabs, so that the currency values they will contain will be properly aligned at the decimal sign.
We are now ready to fill in text from the article database into the table. The properties we need at this point are:
After the user has selected a product in the article database, the program performs these steps:
Some parts are still missing in order to make the quote generator ready for use in an office. For instance, there is no way to search the databases, no comfortable data entry masks, and no way to archive the generated documents.