Postcode Programming API  Street address using COM Object

Street Address Search functionality:

  1. Postcode is entered
  2. User presses search button
  3. Address filled in apart from House Name/Number
  4. User manually types in House Name/Number, unlike Full Address

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 GetThoroughfareAddressRecord to get address from postcode

Simply call GetThoroughfareAddressRecord(Postcode) as Boolean

This type of search will get most of the address, except the house name or number. The user then must enter this information themselves.

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

Simply call with the postcode to search for.

Parameters

Parameter name Description
Postcode as string Postcode to find.

Returns

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


Postcode Lookup Example

This code gets the Street address information from the Royal Mail address database.


                 VB 6   
                   
                   With 
                   SimplyPostCodeLookup 
   PostcodeToSearchFor = "PE13 2QL"
   If .GetThoroughfareAddressRecord(PostcodeToSearchFor) Then
      ‘Process data
      me.Line1 = .Address_line1
      me.Line2 = .Address_line2
   Else
      'Show/Handle any errors
      MsgBox .General_credits_display_text & vbCrLf & .General_errormessage,
                        vbCritical,"Simply Postcode Lookup"

   End If

   'Show Credit/License in form caption
   Me.Caption = .General_credits_display_text
End With


                 VB.NET   
                   
 
                         
                   
                   
                    
                       'Set Data key, to identify your account
SimplyPostCodeLookup.SetDataKey("Your Data Key")

With SimplyPostCodeLookup

   If .GetThoroughfareAddressRecord(Me.txtPostcode.Text) Then
      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
      If .General_errormessage <> "" Then
         MsgBox(.General_credits_display_text & vbCrLf & .General_errormessage,
                  vbCritical, "Simply Postcode Lookup")

      Else
         MsgBox("Not found!")
      End If
   End If

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


                 C# .NET   
                   
                   //Set Data key, to identify your account
string DataKey= "Your Data Key";
string DataToShow= "";
string string crlf = "\r\n";

SimplyPostCodeLookup.SetDataKey(DataKey);

string PostCodeToFind=txtPostcode.Text;
if (SimplyPostCodeLookup.GetThoroughfareAddressRecord(PostCodeToFind) == true)
{
   MessageBox.Show(GetReturnedAddressDataToText( ), "Simply Postcode Lookup");

   DataToShow = " line1 : " + SimplyPostCodeLookup.Address_Line1 + crlf;
   DataToShow = DataToShow + " line2 : " + SimplyPostCodeLookup.Address_Line2 + crlf;
   DataToShow = DataToShow + " line3 : " + SimplyPostCodeLookup.Address_Line3 + crlf;
   DataToShow = DataToShow + " town : " + SimplyPostCodeLookup.Address_Town + crlf;
   DataToShow = DataToShow + " county : " + SimplyPostCodeLookup.Address_County + crlf;
   DataToShow = DataToShow + " postcode : " + SimplyPostCodeLookup.Address_Postcode + crlf;

   //If low credit then can display button to buy more Credits/Licenses
   //This is optional, but it is recommended to provide some means for the end
   //Customer to purchase new Credits/Licenses from Simply Postcode Lookup Direct
   if (SimplyPostCodeLookup.General_credits_display_showbutton==true)
   {
      ButtonBuyMore.Visible = true;
   } else {
      ButtonBuyMore.Visible = false;
   }
} else {
   if (SimplyPostCodeLookup.General_errormessage != "" )
   {
      MessageBox.Show(SimplyPostCodeLookup.General_credits_display_text+" "+
      SimplyPostCodeLookup.General_errormessage, "Simply Postcode Lookup");

   } else {
      MessageBox.Show("Not found!");
   }
}

this.Text = "Simply Postcode Lookup : " + SimplyPostCodeLookup.General_credits_display_text;

Step 4 Testing

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

Postcode Software - COM 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 Street Address unsing the COM object.

Data Returned

This type of license returns: (see example below)

  • Street Name
  • Locality
  • Town
  • County
  • Postcode
  • Country "England","Wales","Northern Ireland","Isle of Man","Channel Islands","Scotland"
  • Mail sort Code