Simply Postcode Lookup                     Phone: 01945 464854 

   Log In       
Postcode Address Lookup Software
 

  Postcode Address Lookup COM Object Programming manual:


  Advantages

  • Out of the box solution Full Postcode Address Search solution 

  • Quick and Simple to add Full Address Search [Show me the code]

  • Offers full access to all data we provide (Full/Thoroughfare/Distance)

  • Offers Advanced Word Search [More information]

  • Can be included in your own installs routines

  • Data always up to date

  • No Data Administration Cost for you

  • Can allow your customer to open an account, your get commission

  • Can be run in local mode [Click here for more information]

  [More About being a Reseller]

  Please download examples here

   Tutorial Video : Programming interfaces & using example code

 

Postcode Address Search COM Object Code Examples:


Install the COM object using “InstallSimplyPostcodeCOM.EXE”

  [How to include your own install package]

The following code is show in the VB, MS Excel and MS access examples included in the example code downloads.   

The most concise and comprehensive example of full Postcode Lookup functionality is the Microsoft Excel sheet, found in the "MS Excel using COM" directory.  This requires the COM Object to be installed first, so please run “InstallSimplyPostcodeCOM.EXE ” first

COM Functionality


Creating the COM Object
Create an Account Manage Account
  Account Status and Postcode Lookup Usage
Full Address using COM UI with Advanced Word Search 
Full Address using COM UI Full Address from COM
Thoroughfare Address from COM
PostZon data (Longitude, Latitude, distance between two Postcodes)
Display Map Get Nearest
Display Best Route
Data Returned How to distribute
Calculating Distance Nearest Store location

 

Exposed functions:


The following functions are exposed by the COM (ActiveX) Object

License related functions

SetDataKey(DataKey as string)

This should be called before an searched, to identify your License.

[More Information]

Open New Account related functions

OpenAnAccountAndLinkToResellerForInternalUse

OpenAnAccountAndLinkToResellerForWebAndInternalUse

OpenAnAccountAndLinkToResellerForWebUse

SetResellerID

These calls open a new Internet browser window and allows the user to open an account with Simply Postcode.  If SetResellerID is called first, with Reseller ID, then the account is linked to a Reseller account for future commission.

[More Information]

ShowAccountAdminPage

This call opens a new browser window and allows the user to log into their account, and thus buy a new license if need be. 

Search related functions: Thoroughfare

GetThoroughfareAddressRecord(Postcode as string) As Boolean

Attempts to find Thorough address, given a Postcode.  Returns true if found and data in appropriate properties.

[Example]

Search related functions: Full address : Quick integration

SearchForFullAddressWithDialogue(...) As Boolean

SearchForFullAddressWithDialogueAdv(...) As Boolean

Shows a dialogue box, which allows the user to perform a FULL Address search.  Returns TRUE if success, and data address data is retruned in the appropriate property fields.

The SearchForFullAddressWithDialogueAdv allows advanced search

[Example]

Search related functions: Full address : Your own user interface

GetFullAddressToList(PostcodeToSearchFor As string) As Boolean

GetFullAddressLineForSelection() As string

GetFullAddressRecord(SelectedListIndex as long) As Boolean

Search for address by calling GetFullAddressToList, then GetFullAddressLineForSelection to retrieve each line for you to display in a list box.   These calls allow you to provide you own User Interface.

Finally GetFullAddressRecord is called to get the Full address information for line the use has selected.  Note the Simply Postcode Object must not be closed in between the GetList and GetRecord calls.

[Example]

Co-Ordinates, Distance, Longitude/Latitude functions: 

GetPostZonAddressRecord(Postcode As string) As Boolean

Gets Full PostZon data record, which contains Longitude and Latitude.  Returns True if found and data in appropriate properties.

[Example]

SetHomePostCode(Postcode As string) As string

If you set "HomePostcode" before calling GetPostZonAddressRecord, then the property PostZon_DistanceToHomePostcode will contain the distance between in km.

GetPostcodeLongLat(Longitude as double, Latitude as double, Postcode As string) As Boolean

Returns  Longitude and Latitude, for given Postcode.  Returns True if found

[Example]

GetDistance(Latitude1 As Double, Longtitude1 As Double, Latitude2 As Double, Longtitude2 As Double) As Double

Returns the distance between in km.

[Example]

Map functions: 

DisplayPrefuredMapArea(Postcode As string) As string

DisplayPrefuredMapStreet(Postcode As string) As string

DisplayPrefuredMapDistrict(Postcode As string) As string

GetUrlforPrefuredMapArea(Postcode As string) As string

GetUrlforPrefuredMapStreet(Postcode As string) As string

GetUrlforPrefuredMapDistrict(Postcode As string) As string

GetUrlDirectoryOfService

DisplayDirectoryOfService

Displays a map showing Postcode, or return url of map

[Example]

Service Directories: Where's my nearest Curry house?

GetUrlDirectoryOfService

DisplayDirectoryOfService

Displays a map showing Postcode, or return url of map

[Example]

Other functions: 

FormatPostCode(Postcode As string) As string

Formats Postcode with correct spacing.  Also converts !"£$%^&*() to number, just in case user is pressing shift while entering numbers.  All search operations call this first.

GetVersion() As string

Returns the version of COM Object

  Local Data functions (CD-ROM Based data): 

The data can be provided on CD-ROM, or by download.  

[Please click here for more information]

LMSetDataPath(DataPath As string)

Sets the location of the data.  Having set this PATH, the Postcode search functions will all use the local data, rather than the Web based database.

This should be set before calling any of the following functions

LMGetSiteCode() As string

LMGetLicienseInfo() As String

LMTryUnlockCode(UnlockCode As String) As String

These functions all handle Licenses.  This allows your software to include the licensing functionality.  Note MANAGER.EXE, which comes with the local version provided this functionality.

[More Information]

LMSetOverideComputerName(ComputerName As string)

As part of the Terms and conditions, if a Web Based program is user for internal use, then each user must be identified.  This call allows you to define the name of the user.

LMUpdateData(InternetIsAvailable as boolean, Title as string) As Boolean

() As String

These functions allow your program to apply data updates.  These are either copied to the data directory, and called with InternetIsAvailable=false.  Or call with InternetIsAvailable=true, to allow application to download and then apply updates.

[More Information]

LMGetLastUpdateDate(DataType as string) As string

Returns the date of last data updated data files in YYYYMMDD format.  This can be used to warn users when data is old.  For full data, 2 months is the suggested warning date.  Thoroughfare and PostZon are less likely to change, so the warning can be 4-6 months.

 

  Royal Mail PAF Address Data returned


General Information:

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

PAF Address Information:

Public Address_Id As String
Public Address_Organisation As String
Public Address_Line1 As String
Public Address_Line2 As String
Public Address_Line3 As String
Public Address_Town As String
Public Address_County As String
Public Address_Postcode As String
Public Address_Country As String

'Note: When using getting Thoroughfare only:
    'Address_Organisation is Not returned
    'Address_Line1 may return road name, but the user must supply the Building 

    'Name/Number in your software, so you will need to prompt them for this data

'Extra Address information contained in PAF data file
Public Address_Deliverypointsuffix As String
Public Address_NoHouseHolds As String
Public Address_Smallorg As String
Public Address_PoBox As String
Public Address_Rawpostcode As String
Public Address_Mailsort As String

Public Address_Unique As String   *
Public Address_UDPRN As String  *
Public Address_Spare As String     *

* = Not available in Local Mode

The UK Address data returned by the call is similar to our Postcode XML Web service.  

   Fields of interest:

Name

Description

id Is only used for our internal use

deliverypointsuffix

This code can be added to the postcode to give a unique reference to each Delivery Point (letterbox) in a Postcode.  Although the UDPRN number is a better source of unique ID.

nohouseholds

Number of house holds at this postcode address

smallorg

Y = Small Organisation

mailsortcode

The Royal Mail offer discount if mail is sorted by this code

udprn

is a unique 8 digit code assigned to each addressable property (Delivery Point). 

unique

gives the unique portion of the address record, in the above example "44".  See Notes

spare

Contains "|" separated data  

Property No, Property Name, Street Name

See Notes

 

 

 

PAF PostZon Data:

Public PostZon_IntroductionDate As String
Public PostZon_Gridrefeast As String
Public PostZon_Gridrefnorth As String
Public PostZon_County As String
Public PostZon_District As String
Public PostZon_Ward As String
Public PostZon_Usertype As String
Public PostZon_Gridstatus As String
Public PostZon_Country As String
Public PostZon_Wardstatus As String
Public PostZon_NHS_code As String
Public PostZon_NHS_region As String
Public PostZon_Latitude_wgs84 As String
Public PostZon_Longitude_wgs84 As String
Public PostZon_OSreference As String 

    'This is not supported at present but may be in future
Public PostZon_DistanceToHomePostcode As String 

    'Distance from Home Postcode

[More information on PostZon Data]

  Creating the COM Object


Option 1 : Create "early bound" COM object 

Add a COM Reference to our COM object, “ISimplyPostCodeCOMClassSimplyPostCodeLookup.dll, within your programming language.  

  Example to create "early bound" COM Object

So we first create the COM object:

Dim SimplyPostCodeLookup As New SimplyPostCode  

This has the advantage that your programming environment will help with syntax, and report compile errors, etc.  On the down side, if the object has not been installed on the client computer then the program will probably crash on execution.

Option 2 : Create a "late bound" object 

  Example o create "late bound" COM Object

Dim SimplyPostCodeLookup As Object

Set SimplyPostCodeLookup = 

         CreateObject("ISimplyPostCodeCOMClass.SimplyPostCode")

This method has the advantage you can handle any errors cause by not having the COM object installed, but your programming environment will not help with syntax etc.  

You will then need to dispose of the object when finished.

Best to use option 1 then switch to option 2 when tested completely.

 

  Specify then Data Key

SimplyPostCodeLookup.SetDataKey(“I_KD352jKKHhk2GAFFKDU”)

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.  Note the prefix “I” or “W” denotes for “Internal” / “Web” use.

You must use the correct Data Key for Internal/Web use. 

  [What is the Web use, Internal use, Full, Thoroughfare and PostZon data mean?]

 

  Example of Full Postcode Address search data using COM User Interface


Simply call SearchForFullAddressWithDialogue(...)

Can be used in local mode [Click here for more information]

This function call will display a dialogue box for the user to enter the postcode to search for.   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.

This takes the following parameters:

PostcodePrima As String, 

Caption As String, 

ShowLicienceDetails As Boolean, 

AllowManageAccount As Boolean, 

DisplayErrors As Boolean) As Boolean

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

PostcodePrima allows you to initiate the search when opened

Caption sets the caption of the dialogue window

ShowLicienceDetails allows the dialogue to show License status.   It is good practice to show this information

AllowBuyMoreButton allows the use to go to their on line account to purchase more licenses

DisplayErrors allows program to show errors.  If off then will simply close and return errors in General_credits_display_text and General_errormessage

  Example to find Address by Postcode

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

  [Click here for data returned]

     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

This code displays the following Postcode Address Lookup window:

 

  Example of Full Postcode Address search data using COM User Interface, with Advanced search


Simply call SearchForFullAddressWithDialogueAdv(...)

This function adds an "Advanced search" button to the above window.  This allows users to enter address words to search for, to return Full address information.

This function is identical to the function discussed above, but has one additional parameter:

PostcodePrima As String, 

Caption As String,

PathToStoreData as string, 

ShowLicienceDetails As Boolean, 

AllowManageAccount As Boolean, 

DisplayErrors As Boolean) As Boolean

The parameter PathToStoreData specifies where the COM Object can store data files need to cache the lookup lists used in the "Advanced Search" section of the window.  This should be on a server so all uses share the files, therefore one update will update all machines the network.   These updates may be made available periodically (twice a year).  When available an extra button appears allow a user to download the updates, which should take only take a few seconds. 

  The Help link takes the user to this page, click here to view help

  The above search will result in:

Advanced address search

 

See the MS Excel or Access for a working example of Advanced search

 

  Example of Searching for Thoroughfare (Street) Address data from Postcode


Simply call GetThoroughfareAddressRecord(Postcode) as Boolean

Can be used in local mode [Click here for more information]

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

If errors occurred, General_credits_display_text or General_errormessage contain License/Error description.

  Example code:

With SimplyPostCodeLookup 

  PostcodeToSearchFor = “PE13 2QL”

  If .GetThoroughfareAddressRecord(PostcodeToSearchFor) Then

    ‘Process data

    me.Line1 = .Address_line1

    me.Line2 = .Address_line2

  [Click here for data returned]

         

  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

 

  [What is the Web use, Internal use, Full, Thoroughfare and PostZon data mean?]

 

   

  Example of Full Postcode Address search data using your own UI


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

Can be used in local mode [Click here for more information]

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

If errors occurred, General_credits_display_text or General_errormessage contain License/Error description.

And then call GetFullAddressLineForSelection() to get each line for list selection for display

  Example code:

First job, get list for address selection.

With SimplyPostCodeLookup

  List.clear

  PostcodeToSearchFor = “PE13 2QL”  

  If .GetFullAddressToList (PostcodeToSearchFor) Then

    ‘Process data

    Line = .GetFullAddressLineForSelection()

    do until Line = “”

       list.AddItem (Line)

       Line = .GetFullAddressLineForSelection()

    loop          

  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

Retrieving residential property only.  To do this simply append “[” to the end of the Postcode.

Retrieving commercial property only.  To do this simply append “]” to the end of the Postcode.

 

After user selects an address from selection window

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

Calling GetFullAddressRecord(SelectedListIndex as long)

Zero being the first item on the list

  Example code:

With SimplyPostCodeLookup

  SelectedListIndex = list.ListIndex

  If .GetFullAddressRecord (SelectedListIndex) Then

    ‘Process data

    me.Line1 = .Address_line1

    me.Line2 = .Address_line2

  [Click here for data returned]

         

  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

  [What is the Web use, Internal use, Full, Thoroughfare and PostZon data mean?]

 

 

  Example of getting Royal Mail PostZon data (Longitude, Latitude)


Can be used in local mode [Click here for more information]

This call will retrieve the PostZon Data for a given Postcode, OSRef,  Longitude/Latitude or "Town, County".   This PostZon data is collected from many different source by the Royal mail.   The most useful information is Distance from Home Postcode (in Kilometers), Longitude and Latitude.

Simply call GetPostZonAddressRecord (Postcode) as Boolean

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

If errors occurred, General_credits_display_text or General_errormessage contain License/Error description.  

To get the PostZon record by OSRef, simply set postcode to the OSRef, when calling GetPostZonData.

 

To get the PostZon record by Longtitude/Latitude, (closest within 10Km) set postcode to the "Longtitude|Latitude" (separated by |). 

 

The Postcode found will be returned in Address_Rawpostcode.

To get the Longitude and Latitude of a Town, simply provide the Town name + “,SPACE“ + County in the postcode field.  The Longitude and Latitude will then be returned.

[Download town list]

  Example code:

With SimplyPostCodeLookup

  PostcodeToSearchFor = “PE13 2QL”  

  .SetHomePostCode(“BH101UI”) ‘Optional for distance

  If .GetPostZonAddressRecord(PostcodeToSearchFor) Then

    ‘Process data

    me.lat = .PostZon_latitude_wgs84

    me.long = .PostZon_longitude_wgs84

    me.Distance = .PostZon_DistanceToHomePostcode

  [Click here for data returned]

        

  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

  Example code, function to get longitude and latitude from postcode:

 

Function GetLongLat(PostCode as string, Long as double, Lat as double) 

                                                      as boolean