Solved

RHS assignment

Posted on 2002-07-16
11
313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 25 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 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