On Sep 30, 2006, at 2:05 AM, Robert Livingston wrote:
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")

A property is a slot in memory that contains a value that you can simply go get, and there is no background involved. A method is a subroutine that you can run that can accept parameters and can return a value, and it is primarily characterized by the presence of code needed to do it's job.

You could also argue that a property is a method with preset code for storing and retrieving a specific data type from memory, and a method is a build-it-yourself situation.

For example, an integer variable declared as a property on a window is a property. You can input a value, you can get the value, and there is no unusual background code related in getting or setting the value.

A method, on the other hand, is basically just more complex. In it's simplest form, you could easily confuse it with a property (except for the fact that all properties are listed under the "Properties" category and all the methods are listed under the "Methods" category).

This is where methods can become similar to properties. There are two keywords that you can apply to your list of properties that change how you call your method: Extends, and Assigns. This is how they change things:

Function Foo(input As Integer) As Integer
... is used....  result = Foo(input)

Function Foo(Extends input As Integer) As Integer
... is used....  result = input.Foo

Function Foo(Assigns input As Integer)
... is used....  Foo = input

So as you can see, you can easily mix and match the above to masquerade a method to be used like a property. As for the inconsistencies in the LR, well, either RB is really weird, or the LR could be inaccurate. I know that I personally mix them up all the time because of how method can look like a property, and with multiple people working on that LR, one can see how differences can occur.

Just for another example, if you wanted to simulate the Cell property of a Listbox, you would do it like this:

Function Cell(Extends lbox As Listbox, row As Integer, col As Integer, Assigns value As String)
  // update variables and refresh the listbox
End Function


HTH
Andrew Keller
_______________________________________________
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>

Reply via email to