Using With to Access Objects

When several methods or properties of a single object need to be referenced, the with statement can be used to reduce the amount of code and, perhaps, to improve execution speed.

Visual Basic | Delphi | C++ Builder

Visual Basic 6.0

As you can see, this syntax is very clear. The leading dots indicate which parameters are associated with commondlg.

Delphi

The following example is from the Delphi with help. Notice that there is no indication that Month is part of OrderDate. Either you notice it or you're completely confused. Since this syntax is fairly confusing, I strongly suggest not using it!

On the other hand, it is supposed to execute faster since the pointer to OrderDate is computed only once and not for each reference.


C++ Builder


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / Languages / With.htm