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.
Pls reply me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
(Check out the object browser)