Solved

VB.Net Currency Conversion (E.g. NZD to AUD)

Posted on 2011-03-02
8
673 Views
Last Modified: 2012-05-11
Hey,

I'm looking to add a currency converter into my vs 2010 application. How would I go about doing this? Reading HTML from a website?

Ideas please.

Thanks!
Jessee
0
Comment
Question by:Letsgetcoding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 35015950
Hi,

If you want to build a new one by yourself then you need to have current/updated Exchange Rates of all the countries you want to support currency conversion.

Please provide details on what exactly you want to build.

Asim
0
 

Author Comment

by:Letsgetcoding
ID: 35016063
It is only going to need to have around about 4 different currencies.

All I am needing is ideas on how to get this information, I can build the rest of it myself.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 35016102
You can use existing webservices to perform this

Currency Conversion Using WebServices
http://www.dotnetspider.com/resources/28835-Currency-Conversion-Using-WebServices.aspx
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:Letsgetcoding
ID: 35016329
Ok, had a look at that site and followed it to the link http://www.webservicex.net/CurrencyConvertor.asmx?WSDL

The server just keeps returning to busy when I try to add a web service reference.

Know of any other sites?
0
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 35016442
In order to build your own, you can use the exchange rate information from the following:
http://www.oanda.com/currency-data/?srccont=belowgraphic
You can process xml from above and build your converter.

I hope it helps.
Asim
0
 

Author Comment

by:Letsgetcoding
ID: 35016609
Ok attached is the code and it seemingly works fine.

Problem is, when I change text in the dropdownlistfromcountry, it the dropdownlisttocountry also changes, and vice versa.

Any ideas why this is?
Private Sub frmEditProduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Get the list Country Supported using Currency from WebService
        'Create a Reference to the WebService
        Dim Currency As CurrencyConverter.Currency
        'Array for Getting the Country List From WebService
        Dim CountryList As System.Array
        'Get the List of Countries
        CountryList = [Enum].GetValues(Currency.GetType)
        'Bind to the DropDownLists
        DropDownListFromCountry.DataSource = CountryList
        'DropDownListToCountry.DataBind()
        dropdownlisttocountry.DataSource = CountryList
        'DropDownListToCountry.DataBind()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Create an Instance to the WebService
        Dim CurrencyConvertor As New CurrencyConverter.CurrencyConvertor
        'Curency Conversion Enum
        Dim Currency As New CurrencyConverter.Currency
        'Get the Currency Rate
        Dim dt As Double = CurrencyConvertor.ConversionRate(System.Enum.Parse(Currency.GetType(), dropdownlistfromcountry.Text), System.Enum.Parse(Currency.GetType(), dropdownlisttocountry.Text))
        MsgBox(String.Format("Converted Amount {0}", dt * Convert.ToDouble(TextBoxRes.Text.Trim)))
    End Sub

Open in new window

0
 
LVL 10

Accepted Solution

by:
Asim Nazir earned 500 total points
ID: 35016624
Since both drop downs are bound to same datasource i.e. CountryList, this is why they both get changed :)
Create a copy of CountryList and bind that copy to one of the drop down. THis will fix this issue.

Asim
0
 

Author Closing Comment

by:Letsgetcoding
ID: 35016669
Works Brilliant! Thanks guys
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question