To get a "Postzon" Geographical Data address from our COM Object we do the following:
The distance between two postcodes can be returned. Simply call with Postcode and “Home postcode” provided in the parameters. Our service will then return the distance in km. So approximate charges could be applied to a customer based on the straight line distance.
This is the main use of PostZon data. Simply call with the target Postcode and the PostZon data service will return the Longitude and Latitude. Ideal for mapping and calculating distances.
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.
The .NET Assembly is for use with any Desktop .NET project. It is written in Framework V2.0 so compatible with any framework from 2 upwards. It is almost identical to our COM object, but is implemented as a .NET Assembly. It is therefore easier to distribute within your .NET project, since it requires no extra files.
The .NET Assembly is in the “NET Assembly” directory of our example code.
Simply include the “ISimplyPostCodeClass.dll” in your application directory.
Note: the .Net Assembly is for desktop applications compiled to 32 bits. It will run fine on 64 bit machines, but will not support an application compiled to 64 bits, as it uses Microsoft MDAC which does not support 64 bits.
Copy the “ISimplyPostCodeClass.dll” in your application directory, and then add it to your project references. This can be found in the “NET Assembly” directory of our example code.
In C# or VB, simply right click on the project in the Solution Explorer. Select “Add Reference”. On the window that opens, click on the Browser tab. Now find and double click on “ISimplyPostCodeClass.dll” to add reference.
The class constructor takes a parameter of a working directory PATH. This directory is used to store the advanced search data used in combos if used. This must be a valid directory, and have WRITE permissions.
VB.NET Public Class Form1 Public SimplyPostCodeLookup As ISimplyPostCodeClass.ISimplyPostCodeClass Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed SimplyPostCodeLookup = Nothing End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SimplyPostCodeLookup = New ISimplyPostCodeClass.ISimplyPostCodeClass(CurDir)
Public Class Form1 Public SimplyPostCodeLookup As ISimplyPostCodeClass.ISimplyPostCodeClass Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed SimplyPostCodeLookup = Nothing End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SimplyPostCodeLookup = New ISimplyPostCodeClass.ISimplyPostCodeClass(CurDir)
C# .NET public partial class Form1 : Form private ISimplyPostCodeClass.ISimplyPostCodeClass SimplyPostCodeLookup; private void Form1_Load(object sender, EventArgs e) string workingDirectoryForWorkingFiles = Directory.GetCurrentDirectory(); SimplyPostCodeLookup = new ISimplyPostCodeClass.ISimplyPostCodeClass(workingDirectoryForWorkingFiles); }
public partial class Form1 : Form private ISimplyPostCodeClass.ISimplyPostCodeClass SimplyPostCodeLookup; private void Form1_Load(object sender, EventArgs e) string workingDirectoryForWorkingFiles = Directory.GetCurrentDirectory(); SimplyPostCodeLookup = new ISimplyPostCodeClass.ISimplyPostCodeClass(workingDirectoryForWorkingFiles); }
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(Me.txtDataKey.Text)
SimplyPostCodeLookup.SetDataKey(Me.txtDataKey.Text)
C# .NET string DataKey="Your Data Key"; SimplyPostCodeLookup.SetDataKey(ref DataKey);
string DataKey="Your Data Key"; SimplyPostCodeLookup.SetDataKey(ref DataKey);
Simply call GetPostZonAddressRecord (Postcode) as Boolean
GetPostZonAddressRecord (Postcode) as Boolean
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.
This call can be used with Local Data or Internet based data.
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 |).
This code will get PostZon data from our database:
VB.NET 'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your Date Key") With SimplyPostCodeLookup 'Set optional Home Postcode to get straight line distance .SetHomePostCode(Me.txtHomePostcode.Text) If .GetPostZonAddressRecord(Me.txtPostcode.Text) Then Long = .PostZon_Longitude_wgs84 Lat = .PostZon_Latitude_wgs84 Distance = .PostZon_DistanceToHomePostcode GetLongLat=true 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
'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your Date Key") With SimplyPostCodeLookup 'Set optional Home Postcode to get straight line distance .SetHomePostCode(Me.txtHomePostcode.Text) If .GetPostZonAddressRecord(Me.txtPostcode.Text) Then Long = .PostZon_Longitude_wgs84 Lat = .PostZon_Latitude_wgs84 Distance = .PostZon_DistanceToHomePostcode GetLongLat=true 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 //Set Data key, to identify your account string DataKey; DataKey = "Your Date Key"; SimplyPostCodeLookup.SetDataKey(DataKey); //Set optional Home Postcode to get straight line distance string OptionalHomePostCode =txtHomePostcode.Text; SimplyPostCodeLookup.SetHomePostCode(OptionalHomePostCode); string PostCodeToFind = txtPostcode.Text; if (SimplyPostCodeLookup.GetPostZonAddressRecord(PostCodeToFind) == true) { //Return PostZon data Lat = SimplyPostCodeLookup.PostZon_Latitude_wgs84; Long = SimplyPostCodeLookup.PostZon_Longitude_wgs84; Distance = SimplyPostCodeLookup.PostZon_DistanceToHomePostcode; } 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;
//Set Data key, to identify your account string DataKey; DataKey = "Your Date Key"; SimplyPostCodeLookup.SetDataKey(DataKey); //Set optional Home Postcode to get straight line distance string OptionalHomePostCode =txtHomePostcode.Text; SimplyPostCodeLookup.SetHomePostCode(OptionalHomePostCode); string PostCodeToFind = txtPostcode.Text; if (SimplyPostCodeLookup.GetPostZonAddressRecord(PostCodeToFind) == true) { //Return PostZon data Lat = SimplyPostCodeLookup.PostZon_Latitude_wgs84; Long = SimplyPostCodeLookup.PostZon_Longitude_wgs84; Distance = SimplyPostCodeLookup.PostZon_DistanceToHomePostcode; } 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;
Simply call:
GetDistance(Latitude1, Longtitude1, Latitude2, Longtitude2) As Double
Final step is to test, to enable easy testing please use our special test postcodes.
Simply download the example code. The code is in the "NET assembly/Csharp NET Assembly Example" or "NET assembly/VB NET Assembly Example" directory of our example downloads.
These two examples demonstrate postcode lookup software using PostZon data.
This type of license returns: (see example below)
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 (accuracy of the geographic data) 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 infromation on Geographic data returned by API