- Neatest way to get a distinct list of phone numbers (without removing original formatting)?
- Friend Structure PhoneNumber
- Private _Raw As String
- Public Property Raw() As String
- Get
- Return _Raw
- End Get
- Set(ByVal value As String)
- _Raw = value
- End Set
- End Property
- Private _Stripped As String
- Public Property Stripped() As String
- Get
- Return _Stripped
- End Get
- Set(ByVal value As String)
- _Stripped = value
- End Set
- End Property
- Sub New(ByVal num As String)
- Raw = num
- Dim RegexObj As New System.Text.RegularExpressions.Regex("[^d]")
- Stripped = RegexObj.Replace(num, "")
- MsgBox(num & vbCrLf & Stripped)
- End Sub
- End Structure
- Dim phones As New List(Of PhoneNumber)
- If master.Phone.Trim.Length > 1 Then
- phones.Add(New PhoneNumber(master.Phone.Trim))
- End If
- For Each x As Person In duplicates
- If x.Phone.Trim.Length > 1 And Not phones.Contains(New PhoneNumber(x.Phone.Trim)) Then
- phones.Add(New PhoneNumber(x.Phone.Trim))
- End If
- Next
- If phones.Count > 0 Then
- master.Phone = phones(0).Raw
- End If
- For i = 1 To phones.Count - 1
- master.Notes &= vbCrLf & "Alt. Phone: " & phones(i).Raw
- Next
- Dim RegexObj As New System.Text.RegularExpressions.Regex("[^d]")
- Dim phones As New Dictionary(Of String, String)
- master.Phone = master.Phone.Trim
- If master.Phone.Length > 1 Then
- phones.Add(RegexObj.Replace(master.Phone, ""), master.Phone)
- End If
- For Each x As Person In duplicates
- x.Phone = x.Phone.Trim
- If x.Phone.Length > 1 And Not phones.ContainsKey(RegexObj.Replace(x.Phone, "")) Then
- phones.Add(RegexObj.Replace(x.Phone, ""), x.Phone)
- End If
- Next
- If phones.Count > 0 Then
- master.Phone = phones.First.Value
- phones.Remove(phones.First.Key)
- End If
- For Each entry As KeyValuePair(Of String, String) In phones
- master.Notes &= IIf(String.IsNullOrEmpty(master.Notes.Trim), "", vbCrLf).ToString _
- & "Alt. Phone: " & entry.Value
- Next