distance between zip-code's and vb.net

Hi,
Is there a program where I give as parameters a startplace, and some extra zipcode's.
I want the distance between the zipcode's. e.g.
start:Amsterdam, places to visit Paris, Madrid, Bruxelles
I sent the zipcodes from the adress in this places to the program and
the return is Bruxelles 200 km, Paris 250 Madrid 1250.
As you maybe see it's sort in the right driving order
I want to sent the parameters from VB.NET.
Thnx.
dgbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne Taylor (webtubbs)Commented:
Google Maps -> http://maps.google.com/
0
dgbAuthor Commented:
Hi,
It's not what I'm looking for. I know this kind of programs. But i want to sent some zipcodes from my program to the program and get the distances as a result back. As mentioned in the question.
Thnx
0
Wayne Taylor (webtubbs)Commented:
Still use Google Maps. Send the web page the parameters, then parse the returned HTML to get the distance. The query will look something like this....

http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=4810%2C+Australia&daddr=5330%2C+Australia&btnG=Get+Directions

Note that those are Australian Zip codes, so experiment and adjust as required.

Wayne
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

vb_jonasCommented:
Pretty cool! But a bit hard to parse the html. Another approach - which is not easier, but has more possibilities it to use google maps api. The drawback there is that you need to setup a webpage somewhere (afaik), and call it from your winforms app.
0
Wayne Taylor (webtubbs)Commented:
>>But a bit hard to parse the html

Not necessarily. Using Regular Expressions help a lot. I should know - it's what QuickEE uses ;-)
0
dgbAuthor Commented:
Hi Webtubbs,
I understand the way of getting the map with the distance in it, but how do i get only the distance.
Thnx
0
vb_jonasCommented:
Hi dgb, I think Webtubbs meant that you download the html page using something like this:

Public Function GetPageHTML( _
           ByVal URL As String) As String
  ' Retrieves the HTML from the specified URL
  Dim objWC As New System.Net.WebClient()
  Return New System.Text.UTF8Encoding().GetString( _
     objWC.DownloadData(URL))
End Function

Dim strFrom as String="London"
Dim strTo as String="Paris"
dim strUrl = "http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=" & strFrom & "&daddr=" & strTo & "&btnG=Get+Directions"
Dim strFullPageHtml As String =GetPageHtml(strUrl)

Then use regular expressions, or something else to find the distance within strFullPageHtml.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vb_jonasCommented:
The piece of html containing the distance looks like this (London - Paris):

id=\"ddr_drivelink_0\"\x3eDrive\x3c/a\x3e:\x3c/td\x3e\x3ctd align=\"right\" nowrap class=\"timedist ul\"\x3e\x3cdiv class=\"noprint\"\x3e\x3cdiv\x3e289\x26#160;mi \x26#8211; about 5 hours 43 mins\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\"pw\"\x3e289\x26#160;mi \x26#8211; about 5 hours 43 mins\x3c/div

Where 289 (look closely), is the distance (in miles). Now it's a bit of fun to find out a nice regular expression to extract that number. :)

0
vb_jonasCommented:
Here's one crude way to get & parse it (no, I could not keep my fingers away):
Public Function GetPageHTML( _
           ByVal URL As String) As String
  ' Retrieves the HTML from the specified URL
  Dim objWC As New System.Net.WebClient()
  Return New System.Text.UTF8Encoding().GetString( _
     objWC.DownloadData(URL))
End Function
    Function GetDistance(ByVal strFrom As String, ByVal strTo As String) As String
        Dim strUrl = "http://maps.google.com/maps?f=d&hl=en&geocode=&saddr=" & strFrom & "&daddr=" & strTo & "&btnG=Get+Directions"
        Dim strFullPageHtml As String = GetPageHTML(strUrl)
        Dim strSearchFor As String
        strSearchFor = "class=\""timedist ul\""\x3e\x3cdiv class=\""noprint\""\x3e\x3cdiv\x3e"
        Dim strSearchEnd As String = "\x26"
        Dim nPosition As Integer
        Dim nPositionEnd As Integer
        Dim strFound As String = ""
        nPosition = strFullPageHtml.IndexOf(strSearchFor)
        If nPosition <> 0 Then
            nPosition = nPosition + strSearchFor.Length
            nPositionEnd = strFullPageHtml.IndexOf(strSearchEnd, nPosition)
            strFound = strFullPageHtml.Substring(nPosition, nPositionEnd - nPosition)
        End If
        Return strFound
    End Function
----
 
Usage:
msgbox("Distance from London to Paris " & GetDistance("London","Paris"))

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.