Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Newbie Questions

Hi guys,

I am totally new to vba programming and wanted to know if anyone could
explain the relationship between classes, objects, methods, and properties.
I bought a good book on vba for excel, but am still a little confused.

Can anyone clarify?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Newbie Questions

An object is an entity such as a workbook, worksheet or range (Like a
noun). In the object browser, objects will usually be refered to as a
class.

an object can have properties (attributes) (properties can themselves be
objects)
Workbook
Name
Worksheets

Worksheet
Name
UsedRange
parent <== also an object (workbook)
Range <== also an object


Range
address
Interior.colorIndex
Font.colorIndex

visually, a range has a background color and a font color. However, in the
object model, the range has an interior (object) which can have a color or
colorindex and the font can have a name, size, color, colorindex. The
reason these are objects is because other types of objects can also have
interiors and fonts. So this makes them reusable.



If the property is not read only, you can assign it a value

Activeworkbook.Worksheets("Sheet1"). Range("A1").Interior.ColorIndex = 3
' Makes the cell A1 red.


A method is like a verb, it performs an action

ActiveWorkbook.Worksheets.Add

adds a new worksheet the active workbook

A class is generally used to refer to a developer defined object that will
usually also have properties and methods created by the developer using a
class module. However, as was stated at the start, a more general view is
that class and object are interchangable.

I am sure others will have useful thoughts as well. Note that none of the
listings used are exhaustive, but are illustrative.

--
Regards,
Tom Ogilvy


"Steve P" <Steve wrote in message
...
Hi guys,

I am totally new to vba programming and wanted to know if anyone could
explain the relationship between classes, objects, methods, and
properties.
I bought a good book on vba for excel, but am still a little confused.

Can anyone clarify?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Newbie Questions

'Class' and 'object' are sometimes used interchangeably. A way to keep
them distinct is to use 'object' to mean an instance of a class. E.g.
Worksheet is a class, and Sheet1 is an object. A property is a
property of an object, e.g. Cells is a property of Sheet1, Value is a
property of each Cell. A method is a procedure for adding, changing,
or deleting properties to an object, or adding or deleting an instance
object of a class. Each class has a prescribed set of properties and
methods that are used to define or alter an object in that class.

Hth,
Merjet


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Newbie Questions

Thank you for that Tom.
Do you ever sleep?
--
Robert



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Newbie Questions

Snow Day <g

--
Regards,
Tom Ogilvy

"Robert" wrote in message
...
Thank you for that Tom.
Do you ever sleep?
--
Robert





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie Questions ? Robert11[_3_] New Users to Excel 2 February 5th 09 04:12 PM
Newbie Questions 02 Christmas May[_2_] Excel Programming 2 June 9th 06 06:46 PM
Newbie add-in questions KR Excel Programming 1 June 8th 06 04:00 PM
newbie questions Eric Excel Worksheet Functions 1 December 14th 04 04:39 PM
Newbie - two questions Bill Burke Excel Programming 4 April 7th 04 09:38 AM


All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"