Link to home
Start Free TrialLog in
Avatar of afterburner
afterburner

asked on

RHS assignment

Can someone explain the RHS value and meaning in a call like this:

Public Property Let MainDB(RHS As String)
   mstrMainDB = RHS
End Property





Avatar of AzraSound
AzraSound
Flag of United States of America image

RHS = Right-Hand-Side

In a property Let statement, you pass a new value to set for the specified property, e.g.:

Text1.Text = "New String"

Here you set the Text1 object's Text property, passing in the value, "New String", which is the RHS value in question
RHS refers to the SIDE of the "=" in an expression.

RHS is the part of the expression the is on the Right-Hand side of the "=".  Similarly, you may see the use of LHS, or Left-Hand Side, meaning the part that is on the Left-Hand side of the "=".

Arthur Wood
Avatar of afterburner
afterburner

ASKER

I dont get it. What is "MainDB"(RHS As String)








In the textbox example, the code for that Text property may look like this:


Public Property Let Text(RHS As String)
    m_strText = RHS
End Property


In your example, MainDB is the name of the property for this class, and RHS is the value passed to the property.  So, for example, any code using this class may do something like:


Dim c As New myClass
c.MainDB = "ABC"
I know it literally means right hand side and left hand side and that these refer to expressions, but that does not seem to help me getting this concept straight I'm sorry to say. When the RHS is passed into this "function", where does it come from and what is it the right hand side of exactly?
AzraSound
So would I be right in thinking then that to make a new property for an object, you state that you want to "set" a property first, and that doing so sets "a variable" to hold the value, and then Let assigns a value, and Get would retrieve it?
Yes, you use Set and Let to hold a local copy of the property value so that it can be retrieved later via a Get.  Set is used for properties that are, themselves, objects.
azrasound
I cant understand the reasoning behind this stuff still, despite my earlier comment and your answer.

I cant seem to differentiate between what is supposed to be the property itself and what is the property's value. Neither can I see why a Set has to use an object, what kind of object that can be, and how the object gets _its_ value.
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thnx Azra.

I could not get the idea that Set was used for objects - first hurdle. Then the RHS thing was a bigger one but I can now see that it is as simple as being equal to the RHS of the assignment which happens through an implicit Let call back in the calling code. (Thought I'd repeat that to myself so it sinks in).

Best regards
aftrbrnr
Glad I could help   :-)