Solved

Source of OBJECT

Posted on 2000-02-17
3
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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