Coding the frmBoundExample form

OK, we just need a few lines in our form to connect to the class and make it work.

9.  Please add the following in the General Declarations section of the form:

Option ExplicitPrivate clsBoundClass As New myBoundClassPrivate bndPublishers As New BindingCollection

Here, we first dim an object variable, clsBoundClass of type myBoundClass. When we instantiate this class, it will become an object in memory. Notice the New keyword. This means that we will not use the SET keyword to set a reference to the class. The first time we touch (reference in any way) the class, it will spring to life.

Next we dim another object variable, bndPublishers of data type BindingCollection. In our sample program, we use the BindingCollection object to bind a data source to two text box controls. So this line of code will permit us to create an instance of a BindingCollection object.

The Binding object represents a property of an object bound to a data field of a data source. We are using the BindingCollection object to bind a data source that has no design-time interface (our class module that is configured as a data source), to a data consumer (the two text boxes on our form).

© 1998 by Wrox Press. All rights reserved.