The User Relationship - Calling Objects

When an object holds a reference to another object, and calls its properties or methods, we have a uses type relationship. Another way to look at this is as a client-server relationship between the two objects. The client calls properties or methods on the server, and gets an appropriate response.

This is the simplest of the relationships, and is one that virtually all Visual Basic programmers are familiar with - so we won't spend much time discussing it.

The user or client simply declares a variable and creates an object:

Dim objItem as LineItem

Set objItem = New LineItem

And then the user calls the object's properties or methods:

objItem.Load "ABC"
MsgBox objItem.Price

When the user is done with the object, they just releases it by setting its reference to Nothing:

Set objItem = Nothing

Probably all of us have used objects, or at least controls, in the Visual Basic programs we've written. Having an object use another object is no more difficult than using an object from a form or code module.