Solved

Source of OBJECT

Posted on 2000-02-17
3
165 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 20 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

864 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now