April 2006
Beginner
1114 pages
98h 16m
English
Recipients is a read/write property. To create a read-only
property, omit the Let and Set procedures. For example, the following code creates a RecipientCount property that returns the number of people set to receive a message:
' Read-only property to get the number of recipients.
Property Get RecipientCount( ) As Integer
Dim value As Integer
If m_Recipients <> "" Then
value = UBound(Me.AddressArray)
Else
value = 0
End If
RecipientCount = value
End Property
' Read-only property to get an array of recipients.
Property Get AddressArray() As String( )
Dim value( ) As String
If m_Recipients <> "" Then
' This is why m_Recipients must end with ;
value = VBA.Split(m_Recipients, ";")
End If
AddressArray = value
End PropertyOK, I got a little tricky there and created two read-only properties. RecipientCount uses AddressArray to convert the string of recipients into an array, and then it counts the number of items in the array. There are other ways to get the count, but this way demonstrates using Me to call a property from within the class itself. Besides, AddressArray might come in handy later on...
Read now
Unlock full access