Private Sub parse_digits(npa As String, digits As String, ph_text As String)

    Dim i As Long, c As String
    
    npa = ""
    digits = ""
    
    i = 0
    While i < Len(ph_text) And Len(npa) < 3
        i = i + 1
        c = Mid(ph_text, i, 1)
        If IsNumeric(c) Then npa = npa & c
    Wend
    
    While i < Len(ph_text) And Len(digits) < 7
        i = i + 1
        c = Mid(ph_text, i, 1)
        If IsNumeric(c) Then digits = digits & c
    Wend

End Sub

Public Sub ReverseNumberLookup(oRecord As IBBDataObject)

    Dim oAddr As CConstitAddress

    If TypeOf oRecord Is CRecord Then
        '*** Got a constituent.  Find the preferred address.
        Dim oRec As CRecord
        Set oRec = oRecord
        For Each oAddr In oRec.Addresses
            If oAddr.Fields(CONSTIT_ADDRESS_fld_PREFERRED) Then Exit For
        Next oAddr
    ElseIf TypeOf oRecord Is CConstitAddress Then
        '*** Got an address.  Use it.
        Set oAddr = oRecord
    End If

    Dim ph As IBBPhone

    For Each ph In oAddr.Phones
        Dim npa As String, digits As String
        Call parse_digits(npa, digits, ph.Fields(Phone_fld_Num))
        If Len(npa & digits) = 10 Then
        
            ' Needs reference to "Microsoft Internet Controls"
            ' Usually found at: C:\WINDOWS\System32\shdocvw.dll
            
            Dim oIE As InternetExplorer
            Set oIE = New InternetExplorer
            oIE.Visible = True
            oIE.Navigate ("http://anywho.com/qry/wp_rl?npa=" & npa & "&telephone=" & digits)
            
        End If
        
    Next ph

End Sub
