first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Book: Level 2: Programming Visual Basic 5.0; Chapter 15 Highlights (1/2): An Introduction to Objects

Objects exist only in temporary memory (RAM). To persist any changes to object properties in permanent memory, use database or text files, or Registry entries.

System Objects

These are the system objects available to Visual Basic at run time:

App Clipboard Forms Printers Screen

For more details, please see "System Objects" (pg. 15-5).

Deriving Pixel Values from the Screen Object

The Width and Height properties of the Screen object return twip values. This unit of measurement is logical. To derive the physical pixel values for a given display adapter, use the TwipsPerPixelX and TwipsPerPixelY properties of the Screen object.

For example, to store the x and y values of the screen resolution in variables lngResX and lngResY respectively we have:

With Screen
    lngResX = .Width \\ .TwipsPerPixelX
    lngResY = .Width \\ .TwipsPerPixelY
End With

Note the use of integer division.

Populating cboMousePointers on frmScreenInfo

The following form is the preferred way to populate cboMousePointers (please see "Changing the Mouse Pointer" on page 15-10 and frmScreenInfo code):

With cboMousePointers
    .AddItem strText
    .ItemData(.NewIndex) = lngItem
End With

This is in contrast to the For-Next form:

For intI = 0 to ItemsToAdd -1
    cboTest.AddItem "SomeText"
    cboTest.ItemData(intI) = SomeNumericValue
Next intI

Unlike the For-Next method of populating cboMousePointers, the use of the NewIndex property above has no regard for the total number of items to be added (contained in ItemsToAdd). It is also immune to unexpected results if the index of ItemData changes when the Sorted property of the combo box is set to True.

NOTE: VB is in control of the index specified in ItemData(<index>), List(<index>), AddItem <string>, <index>, et al. When the Sorted property of the control is set to True, Visual Basic handles almost all necessary string processing to maintain alphabetic order, including changing the index numbers for items as required by the addition or removal of items. You cannot change the Sorted property at run time.

mod date: 1998-10-01T20:39:34.000Z