Postcode Programming API  Getting Street address using the .Net Assembly User Interface

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 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 .Net Assembly

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.

How to distribute .NET Assembly

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.

Step 3 Creating the .NET Assembly

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)


          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);

}

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(Me.txtDataKey.Text)
        
      


          C# .NET   
            
            SimplyPostCodeLookup.SetDataKey(ref DataKey);
        
      

Optional, set Proxy sever details

A function allows the program to define the proxy settings touse when requesting data from our internet server.

Simply call SetProxy(ProxyAddress, usedID, Password, Domain)

Parameters

Parameter name Description
ProxyAddress As String For example "https://proxy:80/"
usedID As String Username to log in to proxy
Password As String Password to log in to proxy
Domain As String Domain of proxy

        VB.NET   
          
          'Set Proxy Server
SimplyPostCodeLookup. SetProxy(”https://proxy:80/”,”Admin”,”Password”,”My Domain”)


        C# .NET   
          
          'Set Proxy Server
SimplyPostCodeLookup. SetProxy(”https://proxy:80/”,”Admin”,”Password”,”My Domain”);

Step 5 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.

Postcode Lookup Example

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


          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= "";
string DataToShow= "";
string crlf = "\r\n";

DataKey = GetDataKey();
SimplyPostCodeLookup.SetDataKey(DataKey);

string PostCodeToFind=txtPostcode.Text;
if (SimplyPostCodeLookup.GetThoroughfareAddressRecord(PostCodeToFind) == true)
{
   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 6 Testing

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

Street Address Search - Example Code 

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 Street address data.

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