On Sep 30, 2006, at 12:05 AM, Robert Livingston wrote:
When is something a property and when a method?
Take the ListBox class as described in the LR
Cell is said to be a method
ListBox1.Cell(1,2) = "Dog"
CellType is said to be a property
ListBox1.CellType(1,3) = True
The syntax of their use seems to be the same. What makes one a
property and the other a method?
Its seems strange to me that you can assign a value to a method.
(ListBox1.Cell(1,2) = "Dog")
Part of the trick is that you can make a method appear to be a property
It's actually one of the things that is very handy about RB
Suppose you has your own class, Foo, and you started out with it like
Class Foo
public property bar as integer
public property baz as string
and you use it for a while and find that when you set the value for
bar you wanted to do something
You could do the following
Class Foo
private property mybar as integer
public property baz as string
public method bar() as integer
return mybar
public method bar(assigns v as integer)
mybar = v
baz = str(mybar)
Now, in the rest of your program NOTHING else had has to change, but
bar is now a method, not a property but it's behavior is as though
it's a property
You could have done the same with a computed property which is more
like a method than an outright property
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>