PAV I VB

From CDYNE Wiki
Jump to navigation Jump to search

PAV-I will be discontinued in March 2013. We sincerely appreciate your support and regret any inconvenience this may cause.

Button click handler:

 1 Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
 2 
 3 Dim service As PavInternationalServiceClient = New PavInternationalServiceClient("paviws")
 4 Dim request As New AddressInternationalRequest()
 5 
 6 'Check each textbox and add corresponding field if the textbox is not empty
 7 Dim availableFields As New List(Of KeyValue)()
 8 
 9 availableFields.Add(New KeyValue() With {.Key = "ORGANISATION", .Value = ""})
10 availableFields.Add(New KeyValue() With {.Key = "SUBBUILDING", .Value = ""})
11 availableFields.Add(New KeyValue() With {.Key = "BUILDINGNAME", .Value = "Rose House"})
12 availableFields.Add(New KeyValue() With {.Key = "BUILDINGNUMBER", .Value = "51-59"})
13 availableFields.Add(New KeyValue() With {.Key = "DEPSTREET", .Value = ""})
14 availableFields.Add(New KeyValue() With {.Key = "STREET", .Value = "Circular Road"})
15 availableFields.Add(New KeyValue() With {.Key = "DEPLOCALITY", .Value = ""})
16 availableFields.Add(New KeyValue() With {.Key = "LOCALITY", .Value = ""})
17 availableFields.Add(New KeyValue() With {.Key = "POSTTOWN", .Value = ""})
18 availableFields.Add(New KeyValue() With {.Key = "COUNTY", .Value = ""})
19 availableFields.Add(New KeyValue() With {.Key = "POSTCODE", .Value = "IM1 1AZ"})
20 availableFields.Add(New KeyValue() With {.Key = "ADDR", .Value = "United Kingom"})  'You may place the country or entire address in this parameter
21         
22 'Check what output fields are required on return
23 Dim returnFields As New List(Of String)()
24 
25 returnFields.Add("RESCODE")
26 returnFields.Add("OUTPUTSTATUS")
27 returnFields.Add("MATCHLVL")
28 returnFields.Add("ADDR")
29 returnFields.Add("ORGANISATION")
30 returnFields.Add("BUILDINGNUMBER")
31 returnFields.Add("BUILDINGNAME")
32 returnFields.Add("SUBBUILDING")
33 returnFields.Add("STREET")
34 returnFields.Add("DEPSTREET")
35 returnFields.Add("LOCALITY")
36 returnFields.Add("DEPLOCALITY")
37 returnFields.Add("POSTTOWN")
38 returnFields.Add("COUNTY")
39 returnFields.Add("POSTCODE")
40 returnFields.Add("COUNTRY")
41 returnFields.Add("COUNTRYCODE")
42         
43 'Convert to array and add to the request 
44 request.AddressFields = availableFields.ToArray()
45 request.ReturnFields = returnFields.ToArray()
46         
47 'Set License key
48 request.LicenseKey = "YOUR LICENSE KEY"
49         
50 'Check if native output is requested
51 request.ReturnNativeOutput = (chkNATIVE.Checked = True)
52         
53 'Call the service
54 Dim response As AddressInternationalResponse = service.VerifyAddressInternational(request)
55 response = service.VerifyAddressInternational(request)       
56         
57 'Update UI with the results - in this example the results returned to a GridView
58 gridview1.DataSource = response.AddressFields
59 gridview1.DataBind()
60 gridview1.AutoGenerateColumns = True