---
title: clsPhone
summary: API reference for clsPhone.
status: draft
owner: SAIF
last_reviewed: 2026-07-24
library: SAIF.Business
reference_type: package
---

# clsPhone

`clsPhone` is a public class in `SAIF.Business.ContactInfo` that stores telephone components, preserves the original stored value and format, and renders phone numbers in multiple business display formats.

## Purpose
- Stores phone-number components such as country code, long-distance indicator, area code, prefix, number, extension, and foreign flag.
- Preserves the originally stored phone value and format while exposing digit-only and numeric views of the same data.
- Formats phone values into standard, dotted, dashed, SAIF, ADP, generic, and foreign output forms.
- Supports clearing, reformatting, duplication, and initialization from raw string or format inputs.

## Context
- Namespace: `SAIF.Business.ContactInfo`
- Assembly/package: `SAIF.Business`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `IsForeign` | `Public Property IsForeign() As Boolean` | Gets or sets whether the phone number should be treated as foreign. |
| `CountryCode` | `Public Property CountryCode() As String` | Gets or sets the foreign country code. |
| `IsEmpty` | `Public ReadOnly Property IsEmpty() As Boolean` | Returns whether all phone-specific stored parts are blank. |
| `LongDistanceIndicator` | `Public Property LongDistanceIndicator() As String` | Gets or sets the long-distance indicator, typically `1`. |
| `AreaCode` | `Public Property AreaCode() As String` | Gets or sets the three-digit area code. |
| `Prefix` | `Public Property Prefix() As String` | Gets or sets the three-digit prefix. |
| `Number` | `Public Property Number() As String` | Gets or sets the four-digit phone number portion. |
| `Extension` | `Public Property Extension() As String` | Gets or sets the phone extension. |
| `StoredVersion` | `Public ReadOnly Property StoredVersion() As String` | Returns the stored raw phone value. |
| `StoredFormat` | `Public ReadOnly Property StoredFormat() As PhoneFormat` | Returns the stored phone format enumeration value. |
| `Value` | `Public Property Value() As String` | Gets or sets the stored phone value and reparses its component parts. |
| `NumericValue` | `Public Property NumericValue() As Decimal` | Gets or sets the stored phone value as digits-only numeric data. |
| `FormattedValue` | `Public ReadOnly Property FormattedValue() As String` | Returns the phone value formatted with the current stored format. |
| `Digits` | `Public ReadOnly Property Digits() As String` | Returns the digit-only characters from the stored phone value. |
| `New` | `Public Sub New()` | Creates a phone object with `PhoneFormat.None` as the stored format. |
| `New` | `Public Sub New(ByVal inPhoneNumber As String, Optional ByVal inPhoneFormat As PhoneFormat = PhoneFormat.None)` | Creates a phone object from a stored phone string and optional format, then parses its parts. |
| `New` | `Public Sub New(ByVal inPhoneFormat As PhoneFormat)` | Creates a phone object with the supplied stored format. |
| `ToFormattedString` | `Public Function ToFormattedString(ByVal inPhoneFormat As PhoneFormat) As String` | Formats the phone using the requested `PhoneFormat` value. |
| `ToFormattedString` | `Public Function ToFormattedString(ByVal inFormatString As String) As String` | Formats the digit string through `String.Format` using the supplied format string. |
| `FormatPhoneNumber` | `Public Shared Function FormatPhoneNumber(ByVal inPhoneNumber As String, ByVal inOutputFormat As PhoneFormat) As String` | Creates a temporary `clsPhone` and returns the supplied phone number in the requested output format. |
| `Clear` | `Public Sub Clear(Optional ByVal inClearForeignStatus As Boolean = False)` | Clears the stored phone parts and optionally resets the foreign flag. |
| `SetFormat` | `Public Sub SetFormat(ByVal inPhoneFormat As PhoneFormat)` | Sets the stored phone format and updates `IsForeign` when the format is foreign. |
| `Duplicate` | `Public Function Duplicate() As clsPhone` | Creates a copy of the phone object with the same stored version, format, and parsed parts. |
| `MarkOld` | `Public Shadows Sub MarkOld()` | Marks the phone object as not modified. |
| `GetID` | `Public Overrides Function GetID() As Decimal` | Returns `0` for the base phone identifier implementation. |

## Behavioral notes
- Setting `Value` clears the parsed fields, stores the new raw value, and calls `UnformatPhone()`.
- For non-foreign numbers, `UnformatPhone()` strips an 11-digit leading `1` into `LongDistanceIndicator` and then parses area code, prefix, number, and extension from the remaining digits.
- `ToFormattedString(ByVal inPhoneFormat As PhoneFormat)` returns `StoredVersion` unchanged when `IsForeign` is `True`.
- `Clear()` empties all phone parts and only resets `IsForeign` when `inClearForeignStatus` is `True`.

## Constraints and usage notes
- `NumericValue` returns `0` when the stored value contains no digits.
- `SetFormat()` sets `IsForeign` to `True` only when the selected format equals `PhoneFormat.Foreign`.
- `GetID()` is hard-coded to return `0` in this class.

## Sources
- `Business\SAIF.Business\ContactInfo\clsPhone.vb`
