Distance betweeen 2 zip codes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Galsaba

    Distance betweeen 2 zip codes

    anyone knows what the formula is for finding a distance betweeen 2 zip codes?

    Aaron
  • Stan Scott

    #2
    Re: Distance betweeen 2 zip codes

    Aaron,

    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.

    You can, however, 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 getDistanceFrom ZipCodes()
    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.homet ownlocator.com/ZipDistance.cfm ?Zip1=" &
    zip1 & "&Zip2=" & zip2
    Set xmlhttp = CreateObject("M icrosoft.XMLHTT P")
    xmlhttp.Open "POST", sendStr, False
    xmlhttp.Send ("<dummy/>")
    resp = xmlhttp.respons eText

    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

    Stan Scott
    New York City

    "Galsaba" <galsaba@aol.co m> wrote in message
    news:2004071716 5638.26080.0000 0026@mb-m28.aol.com...[color=blue]
    > anyone knows what the formula is for finding a distance betweeen 2 zip[/color]
    codes?[color=blue]
    >
    > Aaron[/color]


    Comment

    • Aaron [SQL Server MVP]

      #3
      Re: Distance betweeen 2 zip codes



      --

      (Reverse address to reply.)





      "Galsaba" <galsaba@aol.co m> wrote in message
      news:2004071716 5638.26080.0000 0026@mb-m28.aol.com...[color=blue]
      > anyone knows what the formula is for finding a distance betweeen 2 zip
      > codes?
      >
      > Aaron[/color]


      Comment

      Working...