Vb.Net - Create Google Currency Converter

In this tutorial i am going to share with you how to create a currency converter that will convert amount from one currency to another. By using this web application we can convert as per the latest market currency exchange rates by using Google Finance API Web Service in ASP.Net with VB.Net.

Google Currency Converter

This Application Can Convert Us Dollars To India Rupees , Euro to Japan Yen, and etc.
Now, Let's Create Web page to Create Google Currency Converter.

After Create New Web page Design GUI (Graphical User Interface) as per your requirement.

Vb.Net Code:
Imports System.Net
Imports System.Web.Script.Serialization
Imports System.IO
Imports System.Globalization
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports System.Text.RegularExpressions
 
Public Class WebForm1
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load
 
    End Sub
    Protected Sub btConvert_Click(sender As Object, e As EventArgsHandles btConvert.Click
        Dim Amount As String = CurrencyConvert(txtAmount.Text, ddlFrom.SelectedItem.Value, ddlTo.SelectedItem.Value)
        ClientScript.RegisterStartupScript(Me.[GetType](), "alert""alert('" & Amount & "');"True)
    End Sub
    Private Function CurrencyConvert(ByVal amount As DecimalByVal fromCurrency As StringByVal toCurrency As StringAs String
        '////////////////////////////////////////////// LIKE AND SHARE ////////////////////////////////////////////////////////
        '////////////////////////     https://www.facebook.com/Asppoint1   ////////////////////////////////////////////////////
        '////////////////////////     https://www.asppoint.com/           /////////////////////////////////////////////////////////////
        CurrencyConvert = Nothing
      If amount <> 0 Then
            Dim web As New WebClient()
            Dim url As String = String.Format("https://www.google.com/finance/converter?a={2}&from={0}&to={1}", fromCurrency.ToUpper(), toCurrency.ToUpper(), amount)
            Dim response As String = web.DownloadString(url)
            Dim regex As New Regex("<span class=bld>(\d*.\d*)")
            Dim rate As String = System.Convert.ToDecimal(regex.Match(response).Groups(1).Value)
            CurrencyConvert = "Real-Time Rate: " + ddlFrom.SelectedItem.Value + " = " + rate + " " + ddlTo.SelectedItem.Value
        End If
    End Function
 
End Class
Download Sample Code:
Download Sample Code


Previous
Next Post »

If you have any kind of question about any post, Feel free to ask.You can simply drop a comment below post. Your feedback and suggestions will be highly appreciated. ConversionConversion EmoticonEmoticon