Click here to Skip to main content
15,356,720 members
Articles / Programming Languages / C#
Article
Posted 30 May 2005

Stats

80.4K views
965 downloads
24 bookmarked

Currency Convertor

Rate me:
Please Sign up or sign in to vote.
3.13/5 (19 votes)
30 May 2005GPL31 min read
Converts one currency into another using Yahoo finance exchange rates.

Sample Image - CurrencyConvert.jpg

Introduction

This is a simple tool, that checks the yahoo website for the latest currency rates and converts the given currency into another. It downloads the required exchange rate only when needed and save it for further calculations. So, it saves round way trip again and again to the yahoo website. You can also clear all the downloaded exchange rates. It also shows the latest stock market report. It also automatically checks for any new version available at http://www.priyank.in/ for download, and reports user about the same.

How it works

Actually its internal working is very complex, we have to download the page from yahoo website using HttpWebRequest and HttpWebResponse and apply regular expression to the data, fetch the currency rates, using Regex class' Match function. See, how hard it is, download the page with URL like:

<A href="http://finance.yahoo.com/currency/convert?amt=1&from=USD&to=INR&submit=Convert">
http://finance.yahoo.com/currency/convert?amt=1&from=USD&to=INR&submit=Convert</A>

Replace USD and INR with your currency symbols used by yahoo website and apply a regular expression like:

</td><td\sclass=\"yfnc_tabledata1\">.*?</td><td\sclass=\"yfnc_tabledata1\">
       (.*?)</td><td\sclass=\"yfnc_tabledata1\">

to fetch the data out of the web page. Now, you are able to find out how hard was that.

Sites used for getting exchange rates

Sites used for getting stock market report

.NET Framework

The .NET Framework can be downloaded from the Microsoft website

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Priyank Bolia
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
QuestionTry this link https://www.igolder.com/exchangerate.ashx?from=EUR&to=CAD Pin
Jcmorin21-Sep-11 6:04
MemberJcmorin21-Sep-11 6:04 
https://www.igolder.com/exchangerate.ashx?from=EUR&to=CAD[^]

Change the currency code in the querystring... simple and very fast to use!

C#
System.Net.WebClient client = new System.Net.WebClient();
double rate = double.Parse(client.DownloadString(@"https://www.igolder.com/exchangerate.ashx?from=USD&to=CAD"));

GeneralCode...... Pin
RuchiJ11-Jan-10 0:24
MemberRuchiJ11-Jan-10 0:24 
GeneralRe: Code...... Pin
Priyank Bolia11-Jan-10 0:31
MemberPriyank Bolia11-Jan-10 0:31 
GeneralRe: Code...... Pin
RuchiJ11-Jan-10 0:33
MemberRuchiJ11-Jan-10 0:33 
GeneralDidnt work for me :( Pin
adk_amit7-Mar-09 22:59
Memberadk_amit7-Mar-09 22:59 
GeneralRe: Didnt work for me :( Pin
Priyank Bolia8-Mar-09 1:11
MemberPriyank Bolia8-Mar-09 1:11 
GeneralSource available from Priyank.co.in Pin
Priyank Bolia5-Nov-06 18:09
MemberPriyank Bolia5-Nov-06 18:09 
QuestionSource code would help!! Pin
Sarvesvara (BVKS) Dasa18-Oct-06 8:08
MemberSarvesvara (BVKS) Dasa18-Oct-06 8:08 
QuestionWhere is the code? Pin
emadns30-May-05 19:15
Memberemadns30-May-05 19:15 
AnswerRe: Where is the code? Pin
Ali Iqbal Khan30-May-05 23:19
MemberAli Iqbal Khan30-May-05 23:19 
GeneralRe: Where is the code? Pin
Cugel200528-May-06 13:53
MemberCugel200528-May-06 13:53 
GeneralRe: Where is the code? Pin
pwesson4-Sep-06 1:59
Memberpwesson4-Sep-06 1:59 
GeneralRe: Where is the code? Pin
gk12000123-Aug-10 12:09
Membergk12000123-Aug-10 12:09 
GeneralVery UseFul! Pin
ThatsAlok30-May-05 18:25
MemberThatsAlok30-May-05 18:25 
GeneralRe: Very UseFul! Pin
Priyank Bolia30-May-05 18:36
MemberPriyank Bolia30-May-05 18:36 
GeneralMore than the tool.... Pin
Victor Boctor30-May-05 12:23
MemberVictor Boctor30-May-05 12:23 
GeneralNice! Pin
Ravi Bhavnani30-May-05 6:56
professionalRavi Bhavnani30-May-05 6:56 
GeneralRe: Nice! Pin
Priyank Bolia30-May-05 20:19
MemberPriyank Bolia30-May-05 20:19 
GeneralRe: Nice! Pin
Ravi Bhavnani31-May-05 1:33
professionalRavi Bhavnani31-May-05 1:33 
GeneralRe: Nice! Pin
Priyank Bolia31-May-05 2:49
MemberPriyank Bolia31-May-05 2:49 
GeneralRe: Nice! Pin
Ravi Bhavnani31-May-05 4:44
professionalRavi Bhavnani31-May-05 4:44 
GeneralRe: Nice! Pin
Priyank Bolia31-May-05 18:20
MemberPriyank Bolia31-May-05 18:20 
GeneralRe: Nice! Pin
Ravi Bhavnani1-Jun-05 2:32
professionalRavi Bhavnani1-Jun-05 2:32 
GeneralRe: Nice! Pin
Priyank Bolia1-Jun-05 4:06
MemberPriyank Bolia1-Jun-05 4:06 
GeneralVERY USEFUL Pin
BobbyQSoft30-May-05 6:41
MemberBobbyQSoft30-May-05 6:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.