Postcode Programming API  Full address finder using the COM Object

Full Address Search functionality

  1. Enter postcode to search for
  2. Presents a list of addresses at postcode entered
  3. Address is selected by user
  4. Full address for selection is returned

When using the COM Object, to search by Postcode to get Full address, we have two choices of implementation:

Full Address using the COM Object user interface

Step 1 Sign up for 30 day trial

Simply use the "Sign Up for Trial" link at top right of this page to open a trial account.   We will then send you a data key, which is used to identify your account, when using the following service.

Step 2 Download/Install SimplyPostcode COM Object

The COM Object is for use with any COM compliant language.  You have two choices to install the object on the target computer:

Option 1 Run our install routine

Simply run InstallSimplyPostcodeCOM.exe or InstallSimplyPostcodeCOM.msi from the root of our api example code as admin. This will install and enable the COM object without any user input.

64bit applications

If you wish to use from 64bit applications. You need to run Simply_COM_Obj_64Bits_register_fix.exe, as admin, which alters the registry to enable 64bit applications to use the 32bit COM object.

Option 2 Distribute files in your own install package

The Postcode Software COM Object is in the “COM Object\COM Object Files” directory of our api example code:

  • Microsoft Internet Transfer Control (MSINET.OCX)" OCX control *
  • Msvbvm60.dll to be in application directory
  • mscomctl.ocx to be in application directory
  • SimplyPostCodeLookup.dll *

* = Needs to be registered as a COM object by install routine.

 

Step 3 Creating the COM Object

 

Add a COM Reference to our COM object, “ISimplyPostCodeCOMClass”SimplyPostCodeLookup.dll, within your programming language.

      VB.NET   
        
        Dim SimplyPostCodeLookup As New SimplyPostCode
    
  

 

Step 4 Specify the Data Key

 

The Data Key will have been sent to you via an e-mail when you opened the account. It is also available under the “Data Key” tab of the online admin window.  For the .NET Assembly you should use the data key beginning with "I_".

        VB.NET   
          
          SimplyPostCodeLookup.SetDataKey(“I_KD352jKKHhk2GAFFKDU”)
      
    

 

Step 5 Call SearchForFullAddressWithDialogue to display search window

 

Simply call SearchForFullAddressWithDialogue(PostcodePrima, Caption, ShowLicienceDetails, AllowManageAccount, DisplayErrors)

  This call can be used with Local Data or Internet based data.  But when using Local Data the advanced search is not available.

This function call will display a dialogue box for the user to enter the postcode to search for (or particial address words if using our Web Based data). The user then presses the [FIND] button, and a list of possible addresses is displayed for the entered postcode. The user selects an appropriate address record and the address is returned.

Parameters

Parameter name Description
PostcodePrima As String allows you to initiate the search when opened
Caption As String allows the dialogue to show License status. It is good practice to show this information
ShowLicienceDetails As Boolean allows the use to go to their on line account to purchase more licenses
AllowManageAccount As Boolean allows program to show errors. If off then will simply close and return errors in General_credits_display_text and General_errormessage

 

Returns

 

Returns true if address search completed and General_credits_display_text contains summary of Credits/License status.  

Postcode Lookup Example

This code displays the following Postcode Address Lookup window:

 

      VB 6   
        
        Function GetAddressByPostcode() As Boolean

          

             On Error GoTo Error_loading

             Set SimplyPostCodeLookup = CreateObject("ISimplyPostCodeCOMClass.SimplyPostCode")

          

             SimplyPostCodeLookup.SetDataKey ("Your Data key")

          

             If SimplyPostCodeLookup.SearchForFullAddressWithDialogue("", "Get Address", true, true, true) then

                With SimplyPostCodeLookup

                   me.CompanyName = .Address_Organisation

                   me.Line1 = .Address_Line1

                   me.Line2 = .Address_Line2

                   me.Line3 = .Address_Line3

                   me.Town = .Address_Town

                   me.County = .Address_County

                   me.Postcode = .Address_Postcode

          

                end with

             end if

             Set SimplyPostCodeLookup = Nothing

          

          Exit_error:

          

             Exit Function

          

          Error_loading:

          

             MsgBox "Simply Post Lookup COM Object has not been installed on this PC !!! Please install using 

                         'InstallSimplyPostcodeCOM.EXE'", vbCritical, "Simply Postcode Lookup software"

             Resume Exit_error

          End Function

        
    
  

 

 

 

      VB.NET   
        
        'Set Data key, to identify your account

        SimplyPostCodeLookup.SetDataKey(Me.txtDataKey.Text)

        

        With SimplyPostCodeLookup

           If .SearchForFullAddressWithDialogue(Me.txtPostcode.Text, "Get address using simple call to 

                         .NET Assembly Object", True, True, True) Then

        

              Me.CompanyName.text = .Address_Organisation

              Me.Line1.text = .Address_Line1

              Me.Line2.text = .Address_Line2

              Me.Line3.text = .Address_Line3

              Me.Town.text = .Address_Town

              Me.County.text = .Address_County

              Me.Postcode.text = .Address_Postcode

        

           End If

        End With
    
  


Using .NET Assembly to provide Address Finder

 

 

 

Advanced Search Example

 

This function adds an Advanced Find button to the search window provided by SearchForFullAddressWithDialogue call (See previous section). This allows users to enter address words to search for, to return Full address information:

Advanced search using .NET Assembly

 

When the Advanced Find button is pressed the following is displayed:

 

Advanced postcode search results

 

Results

 

Results of Advanced Postcode Search

  This advanced word search call can ONLY be used with Internet based data

 

Step 6 Testing

 

Final step is to test, to enable easy testing please use our special test postcodes.

See section below for detail on data returned

Postcode Lookup Software Full Address - Example Code 

Simply download the example code.   The code is in the "COM Object/C++ COM Object","COM Object/MS Access 2000 onwards","COM Object/MS Excel using COM", "COM Object/VB6 COM Example","COM Object/VBNET COM 2005" directory of our example downloads.

You must run InstallSimplyPostcodeCOM.EXE included in the above download.

These examples demonstrate postcode lookup software using Full Address.

Full Address using the COM Object and implement your own User Interface:

Firstly follow steps 1,2,3 and 4 above.  Indeed the section above shows the princile behind this searching method.

Step 5 Present a list fo addreses from postcode entered

Simply call GetFullAddressToList(Postcode), with the Postcode the user has entered in search box.

  This call can be used with Local Data or Internet based data. 

Parameters

Parameter name Description
Postcode as string Postcode to find. If using our Internet based data, then the user can enter words, and wildcard, to search for address data.

 

Returns

 

Returns true if address search completed and General_credits_display_text contains summary of Credits/License status. Else errors reported in General_errormessage

Step 6 Call for each line to display

And then call GetFullAddressLineForSelection() to get each line for list selection for display, discussed in next section.

Example Search Code

 

      VB.NET   
        
        'Set Data key, to identify your account

        SimplyPostCodeLookup.SetDataKey(Me.txtDataKey.Text)
         Me.ListBox1.Items.Clear()
         With SimplyPostCodeLookup
           If .GetFullAddressToList(Me.txtPostcode.Text) Then

          

             'Make list + Cancel button visible

             Me.ListBox1.Visible = True

             Me.ButCancelSelection.Visible = True
            'Now Populate the List box

             Dim Line$

             Line = .GetFullAddressLineForSelection()

             Do Until Line = ""

               Me.ListBox1.Items.Add(Line)

               Line = .GetFullAddressLineForSelection()

           Loop
           Else

              MsgBox(.General_credits_display_text & vbCrLf & .General_errormessage,

                                   vbCritical, "Simply Postcode Lookup")

          End If
           Me.Text = "Simply Postcode Lookup : " & .General_credits_display_text
        end With
    
  

 

 

 

      C# .NET   
        
        string DataKey;

        DataKey = "Your Data Key"

        SimplyPostCodeLookup.SetDataKey(ref DataKey);
         ListBox1.Items.Clear();
         string PostCodeToFind = txtPostcode.Text;

          if (SimplyPostCodeLookup.GetFullAddressToList(ref PostCodeToFind) == true) 

          {

            //Make list + Cancel button visible

            ListBox1.Visible = true;

            ButCancelSelection.Visible = true;
            //Now Populate the List box

              string Line="";

            Line = SimplyPostCodeLookup.GetFullAddressLineForSelection();

            while (Line != "")

            {

                ListBox1.Items.Add(Line);

                Line = SimplyPostCodeLookup.GetFullAddressLineForSelection();

            }
          } else {

             MessageBox.Show(SimplyPostCodeLookup.General_credits_display_text + " " + 

            SimplyPostCodeLookup.General_errormessage, "Simply Postcode Lookup");

          }
         this.Text = "Simply Postcode Lookup : " + 

          SimplyPostCodeLookup.General_credits_display_text;

    
  

 

 

 

Step 7 Get Address Record Selected

 

Now get Address record, when user double clicks on address line in selection box

Calling GetFullAddressRecord(SelectedListIndex as long)

Parameters

Parameter name Description
SelectedListIndex as long The index number of the item selected in the listbox. Zero being the first item on the list

 

Returns

 

Returns true if address search completed and General_credits_display_text contains summary of Credits/License status. Else errors reported in General_errormessage

Example get address record

 

      VB.NET   
        
        With SimplyPostCodeLookup

           If .GetFullAddressRecord(Me.ListBox1.SelectedIndex) Then
                      Me.CompanyName.text = .Address_Organisation

              Me.Line1.text = .Address_Line1

              Me.Line2.text = .Address_Line2

              Me.Line3.text = .Address_Line3

              Me.Town.text = .Address_Town

              Me.County.text = .Address_County

              Me.Postcode.text = .Address_Postcode
                    Else

                        MsgBox(.General_credits_display_text & vbCrLf & .General_errormessage, 

                          vbCritical, "Simply Postcode Lookup")

           End If
                     Me.Text = "Simply Postcode Lookup : " & .General_credits_display_text

              End With
    
  

 

 

 

      C# .NET   
        
        int  SelectedIndex=ListBox1.SelectedIndex;

        if (SimplyPostCodeLookup.GetFullAddressRecord(ref  SelectedIndex)==true)

        {

          CompanyName.text = SimplyPostCodeLookup.Address_Organisation; 

           Line1.text = SimplyPostCodeLookup.Address_Line1;      

           Line2.text = SimplyPostCodeLookup.Address_Line2;      

           Line3.text = SimplyPostCodeLookup.Address_Line3;

           Town.text = SimplyPostCodeLookup.Address_Town;  

           County.text = SimplyPostCodeLookup.Address_County;

           Postcode.text = SimplyPostCodeLookup.Address_Postcode;
        } else {

             MessageBox.Show(SimplyPostCodeLookup.General_credits_display_text +  " " + 

                      SimplyPostCodeLookup.General_errormessage,  "Simply Postcode Lookup");

        }
        

        

        this.Text = "Simply Postcode Lookup : " +  

                                     SimplyPostCodeLookup.General_credits_display_text;
    
  

 

 

 

Step 8 Testing

 

Final step is to test, to enable easy testing please use our special test postcodes.

Postcode Software Full Address - Example Code 

Simply download the example code.   The code is in the "COM Object/C++ COM Object","COM Object/MS Access 2000 onwards","COM Object/MS Excel using COM", "COM Object/VB6 COM Example","COM Object/VBNET COM 2005" directory of our example downloads.

You must run InstallSimplyPostcodeCOM.EXE included in the above download.

These examples demonstrate postcode lookup software using Full Address your own User Interface.

Data Returned:

This type of license returns: (see example below)

  • ID
  • CompanyName
  • Line1
  • Line2
  • Line3
  • Town
  • CountyState
  • PostZipCode
  • Country "England","Wales","Northern Ireland","Isle of Man","Channel Islands","Scotland"
  • MailSort
  • Unique
  • DeliveryPointSuffix
  • NoHouseHolds
  • UDPRN  (Royal mail unique id for each address)
  • Spare

see Additional Data Returned by Postcode Finder API for more information

The following return the status of the account and search:

 

    VB.NET   
      
      Public General_confirm As Boolean

          'True if address data returned

      Public General_credits_display_text As String

          'Shows number of Credits/Users  available

      Public General_accountadminpage As String

          'Gives URL of online account  admin page

          'From here the customer can be  more Credits/Licenses

      Public General_errormessage As String

          'Error Message if error

      Public General_credits_display_showbutton As  Boolean

          'True if should show button to  buy more Credits/Licenses OPTIONAL