Wiki Home

VBCompat Prop Decl


Namespace: SQL

VB6 syntax:



[Public|Friend|Private] Property Get MyProp() As MyType
  MyProp = m_MyVar
End Property

[Public|Friend|Private] Property Let MyProp(ByVal
ICanCallThisWhateverIWant As MyType)
  m_MyVar = ICanCallThisWhateverIWant
End Property

VB7 syntax:



[Public|Friend|Private|Protected] Property MyProp() As MyType
  Get
    MyProp = m_MyVar
  End Get
  Set
    m_MyVar = Value
  End Set
End Property

The new syntax isn't bad, but the old one wasn't either, so why change? The really annoying thing that has changed about properties is that you cannot have different accessibility on the Set and Get code (for example, Public Get, Friend Set).


The change was due to the LCD-effect. C# cannot deal with mixed visibility, and will "see" a property with the most restrictive visibility exposed. That is, if you have a Friend Set and a Public Get, C# will rachet down to Friend visibility for both Set and Get. Yeah, lame, I know. But nowhere near as lame as limiting VB.NOT to this extent. What's laughable is dumbing-down VB so C can deal with it. -- Karl E. Peterson

( Topic last updated: 2000.10.16 01:00:48 PM )