Solved

Source of OBJECT

Posted on 2000-02-17
3
151 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

10 Experts available now in Live!

Get 1:1 Help Now