Full Address Search functionality:
When using the .Net Assembly, to search by Postcode to get Full address, we have two choices of implementation:
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.
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 api example code.
Note: the .Net Assembly is for 32bit desktop applications
Simply include the “ISimplyPostCodeClass.dll” in your application directory.
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);
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)
SetProxy(ProxyAddress, usedID, Password, Domain)
VB.NET 'Set Proxy Server SimplyPostCodeLookup. SetProxy(”https://proxy:80/”,”Admin”,”Password”,”My Domain”)
'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”);
'Set Proxy Server SimplyPostCodeLookup. SetProxy(”https://proxy:80/”,”Admin”,”Password”,”My Domain”);
Simply call SearchForFullAddressWithDialogue(PostcodePrima, Caption, ShowLicienceDetails, AllowManageAccount, DisplayErrors)
SearchForFullAddressWithDialogue(PostcodePrima, Caption, ShowLicienceDetails, AllowManageAccount, DisplayErrors)
This call can be used with Local Data or Internet based data.
This function call will display a dialogue box for the user to enter the postcode to search for, or address words if using Advanced Search (Web Based data only). 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 code displays the following Postcode Address Lookup window:
VB.NET 'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your Data Key") 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
'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your Data Key") 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
C# .NET //Set Data key, to identify your account string DataKey; DataKey = GetDataKey(); SimplyPostCodeLookup.SetDataKey(ref DataKey); //This calls the COM object to do all of the work! string PostCodeToFind = txtPostcode.Text; string Title = "Get address using simple call to .NET Assembly Object"; if (SimplyPostCodeLookup.SearchForFullAddressWithDialogue(PostCodeToFind, Title, true, true, true) == 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; }
//Set Data key, to identify your account string DataKey; DataKey = GetDataKey(); SimplyPostCodeLookup.SetDataKey(ref DataKey); //This calls the COM object to do all of the work! string PostCodeToFind = txtPostcode.Text; string Title = "Get address using simple call to .NET Assembly Object"; if (SimplyPostCodeLookup.SearchForFullAddressWithDialogue(PostCodeToFind, Title, true, true, true) == 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; }
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:
SearchForFullAddressWithDialogue
When the Advanced Find button is pressed the following is displayed:
This call can ONLY be used with Internet based data
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 Full Address.
This is a two-step process. First we present a list to the user, then wait for user selection. After selection we retrieve the full address from the database.
Follow steps 1-4 above.
Simply call GetFullAddressToList(Postcode), with the Postcode the user has entered in search box.
GetFullAddressToList(Postcode)
Returns true if address search completed and General_credits_display_text contains summary of Credits/License status. Else errors reported in General_errormessage.
General_credits_display_text
General_errormessage
And then call GetFullAddressLineForSelection() to get each line for list selection for display, discussed in next section.
GetFullAddressLineForSelection()
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
'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;
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;
Now get Address record, when user double clicks on address line in selection box
Calling GetFullAddressRecord(SelectedListIndex as long)
GetFullAddressRecord(SelectedListIndex as long)
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
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;
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;
In the previous two steps we used the NET assembly to remember, in the background, the actual address record IDs used to get the resultant address record. This makes implementing for traditional desktop software easier.
When implementing for a web site we need to store the actual address ID’s in the combo box we allow the user to select from since we cannot keep the state of the NET Assembly alive between calls from the users web page. Indeed the SimplyPostCodeLookup object life is only the duration of the address query.
SimplyPostCodeLookup
To obtain the Address ID and the line information, we use:
.GetFullAddressLineForSelectionWithID(ID as string)
Instead of .GetFullAddressLineForSelection()
.GetFullAddressLineForSelection()
VB.NET Dim SimplyPostCodeLookup = New ISimplyPostCodeClass.ISimplyPostCodeClass(CurDir) 'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your Data key") 'If using Local Mode data files then the following code sets the PATH. 'SimplyPostCodeLookup.LMSetDataPath(DataPATH) Dim PostCode$ = "PE13 2QL"; Me.ListAddresses.Items.Clear() With SimplyPostCodeLookup If .GetFullAddressToList(PostCode$) Then 'Now Populate the List box Dim Line$ = "", ID$ = "" Line = .GetFullAddressLineForSelectionWithID(ID) Do Until Line = "" Me.ListAddresses.Items.Add(New ListItem(Line, ID)) Line = .GetFullAddressLineForSelectionWithID(ID) Loop Else 'Display errror Me.Label2.Text = .General_credits_display_text & vbCrLf & .General_errormessage End If If Me.ListAddresses.Items.Count = 0 Then Me.Label1.Text = "Nothing found..." Me.Label2.Text = "Simply Postcode Lookup : " & .General_credits_display_text End With SimplyPostCodeLookup = Nothing
Dim SimplyPostCodeLookup = New ISimplyPostCodeClass.ISimplyPostCodeClass(CurDir) 'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your Data key") 'If using Local Mode data files then the following code sets the PATH. 'SimplyPostCodeLookup.LMSetDataPath(DataPATH) Dim PostCode$ = "PE13 2QL"; Me.ListAddresses.Items.Clear() With SimplyPostCodeLookup If .GetFullAddressToList(PostCode$) Then 'Now Populate the List box Dim Line$ = "", ID$ = "" Line = .GetFullAddressLineForSelectionWithID(ID) Do Until Line = "" Me.ListAddresses.Items.Add(New ListItem(Line, ID)) Line = .GetFullAddressLineForSelectionWithID(ID) Loop Else 'Display errror Me.Label2.Text = .General_credits_display_text & vbCrLf & .General_errormessage End If If Me.ListAddresses.Items.Count = 0 Then Me.Label1.Text = "Nothing found..." Me.Label2.Text = "Simply Postcode Lookup : " & .General_credits_display_text End With SimplyPostCodeLookup = Nothing
Then we need to get the Address record, when user double clicks on address line in selection box.
This time we call GetFullAddressRecordByAddressID(addressID as string)
GetFullAddressRecordByAddressID(addressID as string)
VB.NET Dim addressID$ = "11570840_0E" Dim SimplyPostCodeLookup = New ISimplyPostCodeClass.ISimplyPostCodeClass(CurDir) 'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your datakey") 'If using Local Mode data files then the following code sets the PATH 'SimplyPostCodeLookup.LMSetDataPath(DataPATH) Dim DataToDisplay$ = "" With SimplyPostCodeLookup If .GetFullAddressRecordByAddressID(addressID$) Then DataToDisplay = "Organistaion:" & .Address_Organisation & "" DataToDisplay += "Line1:" & .Address_Line1 & "" DataToDisplay += "Line2:" & .Address_Line2 & "" DataToDisplay += "Line3:" & .Address_Line3 & "" DataToDisplay += "Town:" & .Address_Town & "" DataToDisplay += "County:" & .Address_County & "" DataToDisplay += "Postcode:" & .Address_Postcode & "" Else 'Display error MsgBox(.General_credits_display_text & vbCrLf & .General_errormessage, vbCritical, "Simply Postcode Lookup") End If DataToDisplay += "Simply Postcode Lookup : " & .General_credits_display_text End With SimplyPostCodeLookup = Nothing
Dim addressID$ = "11570840_0E" Dim SimplyPostCodeLookup = New ISimplyPostCodeClass.ISimplyPostCodeClass(CurDir) 'Set Data key, to identify your account SimplyPostCodeLookup.SetDataKey("Your datakey") 'If using Local Mode data files then the following code sets the PATH 'SimplyPostCodeLookup.LMSetDataPath(DataPATH) Dim DataToDisplay$ = "" With SimplyPostCodeLookup If .GetFullAddressRecordByAddressID(addressID$) Then DataToDisplay = "Organistaion:" & .Address_Organisation & "" DataToDisplay += "Line1:" & .Address_Line1 & "" DataToDisplay += "Line2:" & .Address_Line2 & "" DataToDisplay += "Line3:" & .Address_Line3 & "" DataToDisplay += "Town:" & .Address_Town & "" DataToDisplay += "County:" & .Address_County & "" DataToDisplay += "Postcode:" & .Address_Postcode & "" Else 'Display error MsgBox(.General_credits_display_text & vbCrLf & .General_errormessage, vbCritical, "Simply Postcode Lookup") End If DataToDisplay += "Simply Postcode Lookup : " & .General_credits_display_text End With SimplyPostCodeLookup = Nothing
This type of license returns: (see example below)
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
● see Additional Data Returned by Postcode Finder API for more information