Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Source of OBJECT

Posted on 2000-02-17
3
Medium Priority
?
201 Views
Last Modified: 2010-05-02
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.
0
Comment
Question by:Kelvsat
3 Comments
 
LVL 1

Expert Comment

by:Catouch
ID: 2531794
an object is an element form VB such as a control, form, or code module that holds programming statements.
(Check out the object browser)
0
 

Accepted Solution

by:
arfnarfsi earned 40 total points
ID: 2531845
If you dim a parameter of a subroutine as an object, you could pass it combo boxes, controls and the like (intead of variables).  For example, this could be useful if you had a subroutine that loaded items into a combo, you could call that sub from with different combo boxes as the parameter.

Example:

LoadPartyCombo cmbTPElectionFund
LoadPartyCombo cmbSPElectionFund

Private Sub LoadLibraryCombo(Combo As Object)
    With Combo
        .AddItem ""
        .AddItem "1 - College of Eastern Utah"
        .ItemData(.NewIndex) = 1
        .AddItem "2 - Dixie College"
        .ItemData(.NewIndex) = 2
        .AddItem "3 - Salt Lake Community College"
        End With
End Sub


0
 
LVL 12

Expert Comment

by:mark2150
ID: 2533593
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question