Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Implementing the Print pseudo-method

Status
Not open for further replies.
Apr 13, 2001
4,475
US
As we know, there isn't any easy way to create a VB6 Class using methods and properties named the same as quite a few reserved words. Examples:

[tt]Open
Close
Write[/tt]

Of course by writing the appropriate ODL/IDL and making a typelib we can use Implements to provide class members with such names on an alternate interface for our Class.

But a tricky one is the pseudo-method [tt]Print[/tt] which the compiler handles as a special case. For this one even a typelib doesn't help by itself since the compiler processes the Print keyword in a very different way.

I had thought at one time I had found either an MS KB article or some "Tough Guy's VB" writeup (McKinney or somebody) that offered more details on what goes on under the covers. The upshot seemed to be that the special argument-list syntax was processed into a more digestable form and then some hidden actual method got called on some interface of the object (a Form, a PictureBox, a UserControl, the [tt]Debug[/tt] object, etc.).

Does anybody have this information anymore?

Even the name of the hidden method might help with searches. I'm coming up empty.
 
One example of something similar is the [tt]Width #[/tt] statement.

This compiles as a call to the Sub [tt]VBA.[_HiddenModule].Width[/tt], but I'm looking for something similar for [tt]Print[/tt] (not [tt]Print #[/tt] which is another related beast).

The VB6 manual even provides an "example" of [tt]Width #[/tt] that explicitly calls [tt]VBA.Width[/tt] (letting [tt]_HiddenModule[/tt] fall into place as static module of the VBA library).
 
Ok, so either nobody knows or it doesn't exist and I dreamed it. Good enough.
 
I wouldn't even have tried persuing this if I hadn't been pretty sure it was covered in some MS KB article. So far no luck turning it up though. About all I can find are things like:

PRB: Print Method Does Not Appear in the Object Browser Window or Auto List Members Feature
BUG: Print Method Does Not Work Within a With-Block

These just affirm what we know about [tt]Print[/tt] "methods" and do not go into the actual plumbing under the covers.

Historically some Microsoft products with an automation interface and a [tt]Print[/tt] method have also exported the same method as [tt]PrintOut[/tt] to make it callable from VB and VBA. This does bypass the problem of calling a method name [tt]Print[/tt] but of course does not result in "Print statment" syntax and semantics (use of semicolons and commas, Spc() and Tab() pseudo-functions, etc.).


Thanks for giving it some thought. I've finally convinced a stubborn client to settle for something else.
 
When you go to sleep at night do you dream in vb6 as well? (I still dream in abacus)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top