Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RHS assignment

Posted on 2002-07-16
11
Medium Priority
?
327 Views
Last Modified: 2010-05-02
Can someone explain the RHS value and meaning in a call like this:

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





0
Comment
Question by:afterburner
  • 5
  • 5
11 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 7157740
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
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7157759
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
0
 

Author Comment

by:afterburner
ID: 7157761
I dont get it. What is "MainDB"(RHS As String)








0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 28

Expert Comment

by:AzraSound
ID: 7157765
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"
0
 

Author Comment

by:afterburner
ID: 7157766
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?
0
 

Author Comment

by:afterburner
ID: 7157776
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?
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 7157785
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.
0
 

Author Comment

by:afterburner
ID: 7158214
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.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 total points
ID: 7158577
In order to define a property for a class, you must use the Property Get/Let/Set statements.  A property can be read only, meaning you would only supply a Property Get.  A local copy of the property usually exists so that it can be saved for later retrieval.  Again, an example using a Text property:


Option Explicit

Private m_strText As String  'local copy

Public Property Get Text() As String
    Text = m_strTest   'return what is stored in the local copy
End Property

Public Property Let Text(ByVal RHS As String)
    m_strTest = RHS   'store the passed in, new value, into the local copy
End Property


Now you use set for properties that are objects, just like anytime in VB you use an object and need to set it to something else, e.g.,

Dim t As TextBox
Set t = Text1

Set t = Nothing


If you have a property that is an object, you use Property Set, e.g.,


Private m_objMyPic As StdPicture   'local copy

Public Property Set MyPicture(NewPic As StdPicture)
    Set m_objMyPic = NewPic
End Property
0
 

Author Comment

by:afterburner
ID: 7159109
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
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 7159458
Glad I could help   :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question