4

When you implement an Interface in your Class the arguments are automatically named RHS as shown on MDSN https://msdn.microsoft.com/en-us/library/office/gg264387.aspx

For example, if I create IInterface as so:

Public Property Let Value1(strValue1 As String)

End Property

Public Property Let Value2(strValue2 As String)

End Property

And implement it, the class would look like this:

Implements IInterface

Private Property Let IInterface_Value1(RHS As String)

End Property

Private Property Let IInterface_Value2(RHS As String)

End Property

It's a best practice to name your arguments in such a way as to provide some level of abstraction and make it easier to read and write code. I can actually change the arguments to whatever I want in the class after I've implemented the statements, as shown below, but my question is why does this happen? Is RHS a leftover from another language or is there a particular reason it's named like this?

Implements IInterface

Private Property Let IInterface_Value1(strValue1 As String)

End Property

Private Property Let IInterface_Value2(strValue2 As String)

End Property

The above compiles fine if I manually change it.

Jiminy Cricket
  • 1,377
  • 2
  • 15
  • 24

1 Answers1

4

rhs stands for right hand side of operator = and lhs for left hand side of =. Why is this named like this here? Maybe its something which comes from c++ conventions. By the properties you have consider this code:

Dim test As IInterface
Set test = New ClassTest
test.Value1 = "rhsVal"

The new string value is actually on the right side of the = so therefor rhs.

Daniel Dušek
  • 13,683
  • 5
  • 36
  • 51
  • Thanks for the explanation - looks like it's fairly common in other languages. I wonder why Microsoft overwrote the arguments specified in the actual interface and why they let you overwrite them when implementing in the class – Jiminy Cricket Mar 03 '17 at 13:17
  • `RHS` seems to be used only with property `Let/Set` but why is the code generated this way? Hmmm I do not know. It seems to be a little bug in VBA Editor? – Daniel Dušek Mar 03 '17 at 13:31