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 (2/2): An Introduction to Objects

The Difference between Simple Variables and Object Variables

Simple variables actually store the data they represent. Object variables always store a reference to the physical location of the data. This difference can be seen in the use of the Set keyword when assigning values to object variables:

Set m_frmComboBox = frmTest.cboStates

We cannot use this object variable without declaring it. The declaration is of the form:

Private m_frmComboBox As ComboBox

Visual Basic Object Types

Object hierarchy for forms: Object > Form > <user-defined class name of form>

Object hierarchy for controls: Object > Control > TextBox | List Box | Combo Box

Both specific object types, Form and Control, descend from the generic Object. The use of Object causes VB to implement "late binding" during compilation. The use of specific object types promotes "early binding" (and faster code). For more details please see page 15-21.

Referring to Objects on Forms

Here are three ways to refer to the combo box, cboStates, on the form frmTest:

frmTest.cboStates 'dot syntax frmTest!cboStates 'bang syntax frmTest("cboStates") 'collection object syntax

There is actually an advantage in using the bang syntax. For more details please see page 15-19.

The Concept of Collections

Collections are similar to arrays. Collections are superior to arrays in many ways. Collections can have unique string names as well as the numerical index used in arrays.

Iterating through the Members of a Collection

Use the For Each...Next structure. There is no need to determine the number of elements in the collection.

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