Class

AddressBookData


Warning

This item was deprecated in version 2019r2. There is no replacement.

Description

Used to manage Address Book fields that store multiple values, such as phone and fax numbers.

Methods

Name

Parameters

Returns

Shared

ActualLabel

Index As Integer

String

Append

Label As String, NewValue As Variant

Count

Integer

Insert

Index As Integer, Label As String, NewValue As Variant

Label

Index As Integer

String

Name

String

Remove

Index As Integer

Text

String

Constants

The following class constants can be used to specify the Label parameter of the Insert or Append methods. Not all constants work with all data types. For example, AddressBookContact.EmailAddresses can only use LabelHome, LabelWork or LabelOther. If you use an invalid constant a RuntimeException is raised with the details in the Message/Reason properties.

Constant

Description

LabelHome

Home

LabelHomeFax

Home Fax

LabelMain

Main

LabelMobile

Mobile phone

LabelOther

Other

LabelPager

Pager

LabelWork

Work

LabelWorkFax

Work Fax

Method descriptions


AddressBookData.ActualLabel

ActualLabel(Index As Integer) As String

Returns as a String the label of this data as the system sees it.


AddressBookData.Append

Append(Label As String, NewValue As Variant)

Adds NewValue to the end of the array of property values, identified by Label. Append is for managing multi-value properties such as phone numbers, addresses, email addresses, and so forth. See notes on labels in the description of the Insert method.


AddressBookData.Count

Count As Integer

Returns as an Integer the number of values and labels. See the first example in AddressBookData's Examples section. Count is used to get the number of values to display in a ListBox.


AddressBookData.Insert

Insert(Index As Integer, Label As String, NewValue As Variant)

Inserts NewValue identified by Label. Used to insert multi-value properties such as phone numbers, email addresses, physical addresses, and so forth.

The label should be any of these constants (or literals) defined on AddressBookData:

The following class constants can be used to specify the Label parameter of the Insert method.

Constant

Description

LabelHome

Home

LabelHomeFax

Home Fax

LabelMain

Main

LabelMobile

Mobile phone

LabelOther

Other

LabelPager

Pager

LabelWork

Work

LabelWorkFax

Work Fax

For anything other than phone numbers, the only valid labels are LabelHome, LabelWork, and LabelOther. Passing anything else will raise a RuntimeException. The Message property of the exception will explain the valid labels.

If the property being assigned a value is a custom property or a property that AddressBook the implementation does not know about, it will pass in the label given and not manipulate it in any way.


AddressBookData.Label

Label(Index As Integer) As String

Returns the label as a String belonging to the data.

The possible labels are: Home, Home Fax, Main, Mobile, Pager, Work Fax, Work. If the label isn't one of these, it returns the empty string.


AddressBookData.Name

Name As String

Returns as a String the property name that this data is referring to. For example, "FirstName".


AddressBookData.Remove

Remove(Index As Integer)

Removes the value specified by Index.

This method is for multi-value properties such as phone number, addresses, email addresses, and so forth.


AddressBookData.Text

Text As String

Returns as a String the data this object refers to. If it is a property that holds one value, such as AddressBookContact.FirstName, it returns the value. If it contains multiple strings, it returns the first string.

Sample code

The AddressBookData class can be used to get more information about a field (AddressBookContact properties). The Name method returns the property it represents. The Label method will return what kind of property it is, like Home, Work, etc. The Label property is relevant only for AddressBookData objects that can contain multiple values.

This code gets the user's phone numbers and displays them in a two-column ListBox. The first column displays the label ("Home", "Work", "Mobile", etc.) and the second column shows the phone number.

Dim book As New AddressBook
Dim data As AddressBookData
Dim c, i As Integer

data = Book.CurrentUser.PhoneNumbers
c = data.Count - 1
If data.Count > 0 Then
  For i = 0 To c
    ListBox1.AddRow(data.Label(i))
    ListBox1.Cell(ListBox1.LastIndex, 1) = data.Value(i)
  Next
Else
  MsgBox("No phone numbers!")
End If

This method uses the Value method to get the current user's first email address.

Dim book As AddressBook
Dim myContact As AddressBookContact
book = System.AddressBook
myContact = Book.CurrentUser
MsgBox(myContact.EmailAddresses.Value(0))

Compatibility

All project types on all supported operating systems.