Solved

RHS assignment

Posted on 2002-07-16
11
308 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now