Property Get Value(ByVal Optional index As Long = 0) As String Property Value(ByVal Optional index As Integer = 0) As StringĪn even more intricate case occurs when the Property Get and Property Set block differ for the default value of an optional parameter, as in: In this case, VB Migration Partner uses the Optional keyword for the parameter: (Notice that this is the only case in which a non-Optional argument can follow an Optional parameter.) In VB.NET the “getter” and “setter” blocks of a Property share the same parameters, therefore they can’t differ for the Optional keyword. Property Let Value(ByVal Optional index As Long, ByVal newValue As String) Property Get Value(ByVal index As Long) As String In VB6 it is legal to have a Property Get and a Property Let (or Set) block whose parameters differ for the Optional keyword, as in the following example: Optional parameters in Property procedures
#VB GET ACTIVEX PROPERTY CODE#
VB Migration Partner converts this code to VB.NET as follows:Īlso, notice that the original Property Let and Property Set procedures might have different visibility – Friend and Private, for example – therefore you have to choose the “broader” visibility (Friend, in this case) when you merge them into a single “setter” block. Property Set Owner(ByVal newValue As Variant) Property Let Owner(ByVal newValue As Variant) For example, given the following VB6 code: In most cases you can (and should) simplify the code that is generated by converting and merging the VB6 code verbatim. VB.NET’s Property…End Property block supports only one “setter” block, which must merge code from both original blocks. This is how the property must be translated to VB.NET:Įnd Property Properties with both Let and Set proceduresĪ VB6 property of Variant type can appear in both a Property Let and a Property Set procedure. For example, consider the following VB6 code:įriend Property Let Name(ByVal newValue As String)
During the conversion it is also necessary to account for different scopes of the Property Get block and the Property Let (or Set) block. These procedures are converted into a single Property…End Property VB.NET block, which can optionally be marked with the ReadOnly or WriteOnly keywords if one of the blocks is omitted. Classes and ActiveX components Property proceduresĪ VB6 property is defined by means of its Property Get, Property Let, and Property Set procedures.