Re: Finding the distance between 2 zip codes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tamir Khason (tamir-NOSPAM_at_tcon-NOSPAM.co.il)
Date: 07/20/04


Date: Tue, 20 Jul 2004 19:13:21 +0300

There is no formula for the distance between 2 zip codes. Any system that
provides you with that information has to go to tables containing longitudes
and latitudes and compute the information.

If you want to use it for your own you can purchase this information here:
http://www.aspfaq.com/2527

alternativly, use XMLHTTP to query another Web site and return the
information. This routine is written for Office VBA, and can easily be
adapted to script:

Function getDistanceFromZipCodes()
zip1 = InputBox("Enter Zip Code 1, as xxxxx:", "Zip Code 1")
zip2 = InputBox("Enter Zip code 2, as xxxxx:", "Zip Code 2")
If Len(zip1) <> 5 Or Len(zip2) <> 5 Or Not (IsNumeric(zip1)) Or Not
(IsNumeric(zip2)) Then
MsgBox "Each zip code must be 5 digits long and numeric"
Exit Function
End If

sendStr = "http://gazetteer.hometownlocator.com/ZipDistance.cfm?Zip1=" &
zip1 & "&Zip2=" & zip2
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "POST", sendStr, False
xmlhttp.Send ("<dummy/>")
resp = xmlhttp.responseText

begAns = InStr(1, resp, "<strong>") + 8
endAns = InStr(1, resp, "</strong>")
answer = Trim(Mid(resp, begAns, endAns - begAns))
If answer = "5 digit" Then
MsgBox "Distance cannot be determined"
Else
MsgBox "The distance between Zip Code 1 (" & zip1 & ") and Zip Code
2 (" & zip2 & ") is " & answer & " miles"
End If
End Function

-- 
       Tamir Khason
You want dot.NET? Just ask:
 "Please, www.dotnet.us "
"Galsaba" <galsaba@aol.com> wrote in message
news:20040717165708.26080.00000027@mb-m28.aol.com...
> anyone knows what the formula is for finding a distance betweeen 2 zip
codes?
>
> Aaron


Relevant Pages

  • Re: MySQL Query Optimization
    ... > query can take 15 seconds or more for broader searches. ... What you really need is a precomputed table of distances between zip codes. ... any location in one block is within distance of any location in the other). ... The distance table would consist of pairs of three-digit zones that meet ...
    (comp.lang.php)
  • Re: MySQL Query Optimization
    ... I need to sort the results by distance, ... Is there a simple formula to calculate in my query? ... > fortunately the US population isn't evenly distributed; some zip codes ... > Doing it that way would involve slightly less than 500K entries, ...
    (comp.lang.php)
  • Re: SQL to calculate surrounding suburbs
    ... Here is a function to calculate distance between two lat/lon ... Using this to find all codes within a given distance could ... separately for latitude and longitude - these should be the ... Also watch out for the longitude one if you are near ...
    (comp.databases.ms-sqlserver)
  • Re: SQL to calculate surrounding suburbs
    ... Here is a function to calculate distance between two lat/lon ... Using this to find all codes within a given distance could ... separately for latitude and longitude - these should be the ... Also watch out for the longitude one if you are near ...
    (comp.databases.ms-sqlserver)
  • Re: Its alive!
    ... as california ran out of zip codes. ... I must say I found their system better - all local numbers 7 digits, with 3 extra digits for long distance. ... There's a great Simpsons episode where Springfield get split into 2 area codes. ...
    (uk.comp.sys.mac)