October 9, 1998

Provide Print Preview

You can provide Print Preview at different scales. First, make your printing routine take on the object it should draw as a parameter. Then, for printing, pass the routine the Printer object. For preview, pass the routine a hidden PictureBox. Then use PaintPicture to copy the hidden picture to a

Faster Searches on Arrays, List Boxes, and Combo Boxes

This method is handy when the user enters data that you need to validate against a lookup table. Validating the value by querying the database is out of the question because of the relatively slow response time. An alternative is to keep the lookup table locally in a sorted array,

Sort Data in the Short Date Format

Suppose you have a database field that returns a date in the Short Date format. Neither a numeric sort nor a string sort would order this column correctly. To sort by date, you need to add an extra column to the grid and set its width to zero. Populate the

Progress Bars With A Gradient

The tip “Color Status Indicator” [“101 Tech Tips for VB Developers,” Supplement to the February 1997 issue of VBPJ, page 26] got me thinking that it would look even more attractive to have the status change color in gradient steps. Instead of changing the color at particular points, start at

Compress Short Strings Into a Long Value

When developing relational database applications, you often need to use list boxes or combo boxes to store records with alphanumeric keys. You can load numeric keys into the ItemData array of combo boxes and list boxes as Long integers. Programmers traditionally store alphanumeric keys in a String array with the

Add User Properties to Controls

To add user-defined properties to controls, use this code to store them in the control’s tag. You can define multiple additional properties at design or run time. You can easily retrieve the value stored: Control.Tag = AddParam((Control.Tag), _ “tooltip”, “Close this window.”)Control.Tag = AddParam((Control.Tag), “user”, “True”)Tooltip = GetParam((Control.Tag), “tooltip”)Function AddParam