Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Find distance between two UK postal addresses by using VB within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; To response the recent emails and questions that I’ve been asked of What and How Mappoint together with VB/VB.NET/VBA programming ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Find distance between two UK postal addresses by using VB A well-known restaurant chain has 70 odd branches across the UK. The restaurant Management promote its specific seasonal offers in a regular basis for each their branches only to the customer who lives within 2 miles radius distance. For central London however, 0.5 miles of distance is thought to be appropriate for their direct mailing campaign. Overlapping is strictly prohibited, as it would confuse customer if they receive two letters from two different branches. More than 50,000 of their customer list was given in a format of MS Excel with full address and the UK postcode. A solution was written by using VB.NET that calls an instance of Mappoint to measure the two address one at a time and pick up the qualified record from customer list and then output this record with the store code to a new file. The most important measurement is handled by the following syntax; Radius = locMaster.DistanceTo(oMap.FindResults(dr("PostCode "))(1)) Of course, you need to declare all your variables, including create instance of Mappoint at the beginning of your program; Dim locMaster As MapPoint.Location … objApp = New MapPoint.Application objApp.Units = MapPoint.GeoUnits.geoMiles … I used a loop that loops thru all our customer list by using a SqlDataReader dr(). While dr.Read Radius = locMaster.DistanceTo(oMap.FindResults(dr("PostCode "))(1)) If Radius <= CType(txtRadius.Text, Double) Then txtFileText.Text += strAddress(dr("CustomerID"), dr("Title"), dr("FirstName"), dr("LastName"), dr("Address1"), dr("PostTown"), dr("SubTown"), dr("SubLoca"), dr("County"), dr("PostCode")) & Trim(StoreCode.Text) & vbCrLf iFounder = iFounder + 1 End If If CInt(RecodRequired.Text) = i2Founder Then Exit While End If End While dr.Close() I have also used a loop counter; iFounder to counts how many founds since sometime restaurant requires certain number of records from their list. For example, 200 for central London while 500 for Birmingham’s branch…etc |
| |||
| so... whats wrong with this code
Sub Macro2() ' ' Macro2 Macro ' Macro recorded 06/10/2003 by Daniel Fountain ' Dim objApp As MapPoint.Application Dim objMap As MapPoint.Map Dim objLoc1 As MapPoint.Location Dim objLoc2 As MapPoint.Location Dim objCenter As MapPoint.Location '//open MapPoint and create a new map Set objApp = New MapPoint.Application objApp.Visible = True objApp.UserControl = True objApp.Activate Set objMap = objApp.NewMap objApp.Units = MapPoint.GeoUnits.geoMiles objLoc1 = objMap.FindResults("IP1 5HN")(1) objLoc1.DistanceTo (objMap.FindResults("IP5 3UT")(1)) ' End Sub The error is on the "objLoc1 = objMap.FindResults("IP1 5HN")(1)" line and it says "object vairiable or with block object vairable not set" |
| |||
| syntex is 2002
Which version of Mappoint are you installed on your PC? If it's Mappoint 2000 or earlier, FindResult() has to have City/Town string variable and postcode to together for it to work. don't know why. mine is MP 2002. hope this help. |
![]() |
| Tags |
| addresses, distance, find, postal |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I get the driving distance of two addresses? | dawa | MapPoint 2006/2009 Discussion | 5 | 04-18-2008 01:23 AM |
| Find distance between two addresses | WonderMonkey | MapPoint 2006/2009 Discussion | 0 | 06-26-2006 02:28 PM |
| Why doesn't it find these addresses? | pileggi | MapPoint 2006/2009 Discussion | 0 | 09-13-2005 02:01 AM |
| Calculate Distance Between 2 Street Addresses? | Anonymous | MapPoint 2006/2009 Discussion | 4 | 10-08-2003 05:16 AM |
| Postal Addresses To Coordinate | Anonymous | Wish List | 2 | 05-06-2003 09:53 AM |
Antalya Holiday
Check out the Antalya holiday options through UlookUbook and find amazing offers that suit your pocket...