#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jun 2006
    Posts
    24
    Rep Power
    0

    Live Currency Conversion using Google


    Hey

    I needed to do some currency conversion and it turned out really simple, thought I'd share the function:

    Code:
    Private Function convertcurrency(fromcurrency, tocurrency, amount, decimalplace)
    	url = "http://www.google.com/ig/calculator?hl=en&q=" & amount & fromcurrency & "%3D%3F" & tocurrency
    	set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") 
    	xmlhttp.open "GET", url, false 
    	xmlhttp.send "" 
    	output = xmlhttp.responseText 
    	set xmlhttp = nothing 
    		
    	output = Split(output,"""")
    	arrconverted = Split(output(3)," ")
    	convertcurrency = Round(arrconverted(0),decimalplace)
    End Function
    PS this forum seems to be adding a space to "decimalplace"
    Last edited by Shadow Wizard; May 26th, 2010 at 10:21 AM.
  2. #2
  3. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    Originally Posted by jazzy639
    PS this forum seems to be adding a space to "decimalplace"
    indeed, that's part of the "break long words" mechanism of the
    forums that prevent horizontal scroll bar.. I fixed that by
    spacing the parameters of the function.

    thanks for sharing!
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Oct 2011
    Posts
    1
    Rep Power
    0

    Error


    I'm recieving an error when using this code.
    anyone tell me where i'm going wrong?

    Error:
    msxml3.dll (0x80072EFE)
    The connection with the server was terminated abnormally
    /test/cur.asp, line 11

    Code:
    Code:
    <html>
    <head>
    </head>
    <body>
    <%
    Private Function convertcurrency(fromcurrency, tocurrency, amount, decimalplace)
    	url = "http://www.google.com/ig/calculator?hl=en&q=" & amount & "+" & fromcurrency & "+in+" & tocurrency
    
    	set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") 
    	xmlhttp.open "GET", url, false
    	xmlhttp.send "" 
    
    
    	output = xmlhttp.responseText 
    
    
    	set xmlhttp = nothing 
    		
    	output = Split(output,"""")
    	arrconverted = Split(output(3)," ")
    	convertcurrency = Round(arrconverted(0),decimalplace)
    End Function
    
    response.write(convertcurrency("USD","GBP",1,2))
    %>
    </body>
    </html>

Similar Threads

  1. Excel currency conversion help?
    By sk01 in forum Visual Basic Programming
    Replies: 0
    Last Post: August 16th, 2006, 04:21 PM
  2. Excel currency conversion macro!?!?!?
    By sk01 in forum Programming Help
    Replies: 0
    Last Post: August 16th, 2006, 04:18 PM
  3. Google offers live traffic maps on cell phones (Reuters)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: July 25th, 2006, 11:05 AM
  4. Google offers live traffic maps on cell phones (Reuters)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: July 25th, 2006, 06:03 AM
  5. conversion of Currency (Number) into Words in ASP
    By Steve Schofield in forum ASP Development
    Replies: 0
    Last Post: March 8th, 2002, 01:13 AM

IMN logo majestic logo threadwatch logo seochat tools logo