Solved

RHS assignment

Posted on 2002-07-16
11
307 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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 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…

744 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

10 Experts available now in Live!

Get 1:1 Help Now