Solved

Source of OBJECT

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

828 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