Creating the COM Object
Option
1 : Create "early bound" COM object
Add
a COM Reference to our COM object, “ISimplyPostCodeCOMClass”
SimplyPostCodeLookup.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 (or address words if using our Web Based data,
more
info). 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.

The display of Postcode
search can be by-passed by calling with Postcode Prima="ADV".
This function is
identical to the function discussed above, but has one additional
parameters:
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 (e.g. D:\TempData. 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:

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 (or address
words if using our Web Based data,
more
info).
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
‘Get
Longitude and latitude give a postcode
GetLongLat=false
Dim SimplyPostCodeLookup as object
Dim DataKey as string
DataKey=”I_ndjshfkkgkasgfk”
Set SimplyPostCodeLookup =
CreateObject("ISimplyPostCodeCOMClass.SimplyPostCode")
with SimplyPostCodeLookup
‘This is for the local version of the data
'miss out to use Web based data
.LMSetDataPath (“D:\MYDATA”)
.SetDataKey (DataKey)
‘Get PostZonData
if .GetPostZonAddressRecord(PostCode) then
Long
= .PostZon_Longitude_wgs84
Lat = .PostZon_Latitude_wgs84
GetLongLat=true
end if
end with
Set SimplyPostCodeLookup = Nothing
end
function
[Returned
Data]
[What
is the Web use, Internal use, Full, Thoroughfare and PostZon data
mean?]
Calculating Distance from Longitude,
Latitude
Can be used in local mode [Click
here for more information]
The above function
returns the distance between two Postcodes, but we offer the
following function to allow you to workout the distance between two
address, given the Longitude, Latitude:
GetDistance(Latitude1 As Double, Longtitude1 As Double, Latitude2 As Double, Longtitude2 As Double) As Double
Returns in Kilometers
This function can be used
if you want to workout the nearest store address to as customers entry,
since the Longitude and Latitude can be stored for all of your
stores. Then simply call this and sort to get the nearest
store.
Manage Account online
Manage Your Account online
SimplyPostCodeLookup.ShowAccountAdminPage()
Account Status and Postcode
Lookup Usage
You may want to provide a screen to show the
Simply Postcode account status, in your software, or for you
customer. We provide
this functionality on our web server, this can be access from the
link on the e-mail first sent to you when opening an account or from
the
[Licenses Status and Usage] link on the first page of
your on line account.
It is advisable to bookmark this page, for easy
access.
It shows you:
- Graph of Postcode Lookup usage
- PAF licenses, with credit count or number
of users
- Date predicted to expire, if credit based
license
- Simple links allow you to top up your
account or add extra users *
- Shows if you have an outstanding invoice
with us *
* = not if a resellers customer, on direct
invoice mode
Get/Display Maps
Simply make a call to the
following functions get the URL or display a map based on the
Postcode, at one of three zoom levels.
GetUrlforPrefuredMapArea(postcode)
GetUrlforPrefuredMapDistrict(postcode)
GetUrlforPrefuredMapStreet(postcode)
DisplayPrefuredMapArea(postcode)
DisplayPrefuredMapDistrict(postcode)
DisplayPrefuredMapStreet(postcode)
Get/Display Nearest
Simply make a call to the
following functions get the URL or display a directory of services
nearest to Postcode, for Keywords.
GetUrlDirectoryOfService(PostcodeOrTown, KeyWords,
Optional TypeOfService$ = "Service")
DisplayDirectoryOfService(PostcodeOrTown,
KeyWords,
Optional TypeOfService$ = "Service")
Example code:
So
calling DisplayDirectoryOfService("PE132QL","Hospital","Service")
will list hospitals in area
Get Nearest Store Location
The COM Object has a
whole host of functions for retrieving the nearest Store (in your
own database) location to a Target Postcode.
[Click here for
more information on find Nearest Store Location functionality]
Display Route on Map
Simply make a call to the
following functions get the URL or display a Map with a best route
superimposed.
GetUrlDirectoryOfService(HomePostcodeOrTown, ListOfPostcodes,
"Route")
DisplayDirectoryOfService(HomePostcodeOrTown, ListOfPostcodes,
"Route")
where
HomePostcodeOrTown is the start point
and
ListOfPostcodes is a list of delivery address (comma
seperated)
Example code:
So
calling DisplayDirectoryOfService("PE132QL","PE132XQ,DG14BX","Route")
will display map of route
Get COM Version
SimplyPostCodeLookup.GetVersion()
Create an account
Create an account and assign you as the reseller. It can
link your own Reseller account to a customers so you get commission
on ALL purchases. Please apply to be a reseller at http://www.simply-postcode-lookup.com/Reseller.htm
SimplyPostCodeLookup.SetResellerID( 4 )
The call one of:
Internal Use
'For Internal Use (All Desktop Software and
Web Software used internally within a company)
SimplyPostCodeLookup.OpenAnAccountAndLinkToResellerForInternalUse
or call
http://www.simplylookupadmin.co.uk/A2CustomerAccount/
WebAccountCreateFromReseller.aspx ?r=I&id=4
Web Use
'or For Web Use (All Web Software used by
customer)
SimplyPostCodeLookup.OpenAnAccountAndLinkToResellerForWebUse
or call
http://www.simplylookupadmin.co.uk/A2CustomerAccount/
WebAccountCreateFromReseller.aspx ?r=W&id=4
Both
SimplyPostCodeLookup.OpenAnAccountAndLinkToResellerForWebAndInternalUse
Get License Information
This call allows the Reseller to check a customer Internet based
license, to make sure the customer is attached to them as Reseller,
and check demo status.
It should be called after
setting the Datakey, with the type of search you are interested in
testing. F=Full Address, T=Throughfare Address, Z=PostZon
SimplyPostCodeLookup.SetDataKey
(Me.txtDataKey)
SimplyPostCodeLookup.GetInternetLicenseDetails SearchType$,
errormessage$, validlicense$, licensestatustext$, _
ondemo$, demoarea$, demoexpire$, REID$
Dim t$
t = "errormessage:" & errormessage &
vbCrLf
t = t & "validlicense:" &
validlicense & vbCrLf
t = t & "licensestatustext:" &
licensestatustext & vbCrLf
t = t & "ondemo:" & ondemo & vbCrLf
t = t & "demoarea:" & demoarea &
vbCrLf
t = t & "demoexpire:" & demoexpire &
vbCrLf
t = t & "REID:" & REID & vbCrLf
MsgBox t
Returns:
|
Name
|
Description
|
|
errormessage
|
Description of
error if fails
|
|
validlicense
|
“yes” if a license
exist for this user for SearchType, else "no"
|
|
licensestatustext
|
Text describing the license and its
status
|
|
ondemo
|
“yes”
if on demo, else "no"
|
|
demoarea
|
Postcode area of
demo
|
|
demoexpire
|
Date demo will expire if on demo
|
|
REID
|
Reseller ID
|
An
account can have a valid license and still be on evaluation.
Thus allowing a user to test another service, as well as
having an actual license.
But if a valid license is found, for SearchType, then “ondemo” will
be “no”.
|