Link to home
Start Free TrialLog in
Avatar of Kelvsat
Kelvsat

asked on

Source of OBJECT

How can i get know more method of using 'object', which mean in Dim aa as Object. What is the Object function and how to use it?

Pls reply me.
Avatar of Catouch
Catouch

an object is an element form VB such as a control, form, or code module that holds programming statements.
(Check out the object browser)
ASKER CERTIFIED SOLUTION
Avatar of arfnarfsi
arfnarfsi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
An object is also how you can make a print preview function out of the same routine that does the real printing. Instead of coding Printer.Print or Printer.CurrentX, etc. You define a passed object:

Public Sub Render(Obj as Object)

Then inside the routine you code:

Obj.Print ...

or

Obj.CurrentX = ...

If you want screen preview, pass it a picture box control. If you want hard copy output, pass it the Printer object:

DIM MyObj as Object
Set MyObj = Printer
Call Render( MyObj )

The above will print. If you change to:

Set MyObj = Picture1

Then you'll get a print preview. Sometimes you need to know what kind of object you're printing to, for instance you can't .CLS or .BackColor the printer and you can't .EndDoc a picturebox. You use the TypeName function to determine what is which so you can bypass object specifics when needed.

You also use objects when you want to perform a common operation on all objects in a form.

M