What is the difference between a property a method and an
event? Give an example of each.

Answer Posted / chris barry

There is very little difference between VBA methods and
properties. A property is not analagous to a Java field, it
executes a class procedure just as a method does. The main
difference is that a property can be the left side of an
assignment.
Class methods are defined using the Function and Sub
keywords just as they would be used outside a class. User
defined properties use the Property key word together with
Get, Set or Let. A "Property Get" procedure seems almost
indistinguishable from a "Function" except that if there is
a corresponding "Property Let" then the compiler may check
that the type returned by "Get" is the same as the type
accepted by Let.
A "Property Let" procedure is defined as a normal function
with at least one argument, but it is called with one
argument fewer. The final argument takes its value from the
right side of the assignment. e.g.

Dim arr(4) As Integer
Property Let element(idx, val)
arr(idx) = val
End Property

could be called as:

ClassName.element(1) = 2

An event is something that happens asynchronously to the
main thread of the application, which can be linked to a
user-defined procedure (an event handler) which will be
invoked when the event occurs. In VBA at least, events are
most commonly generated by controls responding to user
actions.

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you create your application in DHTML?

1516


how to use telugu language in vb6? any unicode data is available for telugu or not?yes means how to use? my desired output is telugu only? i am doing project like(telugu calendar),my output should be print in telugu only? pls send me the solution with code?

2984


How many ways you can access file using VB?

564


Types of LockEdits in RDO.

1693


How would you Create a Query Builder and Explain its uses ?

1610






___ is the control used to call a windows application.

1071


What are 3 main differences between flexgrid control and dbgrid control?

1693


___ argument can be used to make a menuitem into bold.

1281


What are the new events in textbox that has been included in VB ?

1338


Is it possible to set a shortcut key for label?

1387


What is form in visual basic?

518


What is the use of debug Window?

1536


How to use hyperlink?

580


Why do I get "object not an array" when I try reference the fields of a global object variable which I have set to a table?

1142


What are the types of API Types.

1682