So the property doesn't do anything other than capture a variable sent over by the main module? Am I understanding it correctly?
Main Topics
Browse All TopicsI'm having trouble understanding the purpose of class properties. I just made a class called NumberChanger. Ultimately, all I want to do is make a class that takes an integer sent over my a module and multiplies it by 2. What does the property in this class do exactly?
Public Class NumberChanger
Public Number As Integer
Public Property Changer() As Single
Get
Return Number
End Get
Set(ByVal Value As Single)
Number = Value
End Set
End Property
Public Function ChangeNum()
Number = Number * 2
Return Number
End Function
End Class
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Almost, yes.
Public Number As Integer
This is a "dumb" property. The routine using the class can manipulate <obj>.Number just like a variable -- it is just a variable; the class can modify the value as well.
Private MyNumber As Integer
Public Property Number() As Integer
Get: Return MyNumber: End Get
Let (Val As Integer): MyNumber = Val: End Let
End Property
This is the same in more words. The hidden variable is manipulated through gateways, automatically invoked when the calling code issues:
WhatIs = <obj>.Number ' get the value
Let <obj>.Number = 101 ' 'let' is usually omitted
The entire idea of Property Let/Get functions is that they can have side effects, perform validation, or implement calculated properties.
The class below (untested air code) has an auto-validating °K temperature property, and correlated °C and °F properties. You could also implement a single property Temp(Optional °X = °K) As Single, a parametrized property, defaulting to Kelvin, but managing Celsius and Fahrenheit as well.
(°v°)
Business Accounts
Answer for Membership
by: harfangPosted on 2009-11-07 at 22:02:22ID: 25769559
The property Changer does nothing more than the property Number. Both are read/write properties of the class, just a different syntax.
If you want to be picky, the property performs Single to Integer conversion on write and Integer to Single conversion on read.
Also, the property is buggy, it's a Let property, not Set.
(°v°)