5 Minute Developer: How to Build a Currency Converter in 5 Minutes

First Published Saturday, 30th January 2010 03:06 pm from Xand : ChasCooper

The opinions expressed by this blogger and those providing comments are theirs alone, this does not reflect the opinion of Automated Trader or any employee thereof. Automated Trader is not responsible for the accuracy of any of the information supplied by this article.


href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"> src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

height="61" width="51" />

Every

five minutes, a business in the U.S.

href="http://crm.cr.nps.gov/archive/24-08/24-08-5.pdf"

target="_blank">catches fire, someone in the UK

href="http://www.telegraph.co.uk/news/uknews/6230569/Swear-words-heard-once-every-five-minutes.html"

target="_blank">swears, and a clock that took 5

years and £1 million to build before being unveiled by none

other than Stephen Hawking, finally

href="http://news.bbc.co.uk/2/hi/7625815.stm"

target="_blank">tells the time accurately for a

second or two.

What will you do with your next

5 minutes?

Here's a thought: Why not build a

href="http://www.xignite.com/forex/web-service/2000106.html">real-time

forex currency converter? Sound like fun? If so, give

it a try using the steps below. Or, if you'd rather

leave all the fun to someone else, why not just href="http://www.xignite.com/forex/web-service/2000106.html"

target="_self">watch a video of us doing

it?

Here's how

it's done:

Step

1: Start a new Windows application project in

Visual Studio.

Step 2:

Create a Web reference to

http://www.xignite.com/xCurrencies.asmx?WSDL and call it

XigniteCurrenciesService.

Step

3: On the Form1 design, drag and drop 3 text

boxes, 2 labels, and a button, arranging them as shown in the

picture. From left to right, give the text boxes the following

names and default text: inputBaseAmount defaulting to 1000,

inputBaseSymbol defaulting to USD, inputQuoteSymbol defaulting to

EUR. One label should have a big equal sign in it and the other

should have the name of labelQuoteAmount and zero for its text

property. The button should read "Convert."

src="http://cdn.xignite.com/blog/02_01_10/5min_currency_converter_v1a.png"

alt="Real-Time Forex Currency Converter Built in 5 Minutes"

/>

Step 4:

Double-click the button to create its click event

handler, and give it the following 3 lines of code:

XigniteCurrenciesService.XigniteCurrencies

XigniteCurrenciesWebService = new

XigniteCurrenciesService.XigniteCurrencies();

XigniteCurrenciesService.ExchangeConversion Quote =

XigniteCurrenciesWebService.ConvertRealTimeValue(inputBaseSymbol.Text,

inputQuoteSymbol.Text,

double.Parse(inputBaseAmount.Text));

labelQuoteAmount.Text =

Quote.Result.ToString();

Step 5:

Compile and run.

Authentication trouble? If

you get an authentication error, it means you're not

being authenticated from a cookie or your IP address.

Don't worry. Just add 3 more lines after the first line

of code to pass your authentication key through SOAP. Be sure to

replace MYAUTHENTICATIONKEY with your own Xignite account

authentication key. (Don't have an authentication key? Just href="http://www.xignite.com/forex/getting-started/2000111.html"

target="_self">sign up to get one. Your e-mail will

be your initial authentication

key.)

XigniteCurrenciesService.Header

objHeader = new XigniteCurrenciesService.Header();

objHeader.Username =

"MYAUTHENTICATIONKEY";

XigniteCurrenciesWebService.HeaderValue =

objHeader;

Congratulations!

You just spent the last five minutes far more

productively than one U.S. business, one citizen of the UK, and

one very expensive but very inaccurate clock.

Share and

Enjoy:

href="http://digg.com/submit?phase=2&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Digg"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/digg.png"

title="Digg" alt="Digg" class="sociable-hovers" />

href="http://del.icio.us/post?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="del.icio.us"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/delicious.png"

title="del.icio.us" alt="del.icio.us" class="sociable-hovers"

/>

href="http://www.facebook.com/share.php?u=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&t=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Facebook"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/facebook.png"

title="Facebook" alt="Facebook" class="sociable-hovers"

/>

href="http://www.google.com/bookmarks/mark?op=edit&bkmk=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Google"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/googlebookmark.png"

title="Google" alt="Google" class="sociable-hovers"

/>

href="https://favorites.live.com/quickadd.aspx?marklet=1&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Live"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/live.png"

title="Live" alt="Live" class="sociable-hovers" />

href="http://reddit.com/submit?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="Reddit"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/reddit.png"

title="Reddit" alt="Reddit" class="sociable-hovers"

/>

href="http://slashdot.org/bookmark.pl?title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="Slashdot"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/slashdot.png"

title="Slashdot" alt="Slashdot" class="sociable-hovers"

/>

href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes"

title="StumbleUpon"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/stumbleupon.png"

title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers"

/>

href="http://technorati.com/faves?add=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="Technorati"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/technorati.png"

title="Technorati" alt="Technorati" class="sociable-hovers"

/>

href="http://twitter.com/home?status=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="TwitThis"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/twitter.gif"

title="TwitThis" alt="TwitThis" class="sociable-hovers"

/>

href="http://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F&title=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&source=Financial+Market+Data+Web+Services+-+Xignite+Blog+It%27s+not+the+data.++It%27s+the+delivery.&summary=In%205%20minutes%2C%20build%20a%20real-time%20forex%20currency%20converter%20application%20using%20Visual%20Studio%2C%20C%23%20and%20Xignite%27s%20XigniteCurrencies%20web%20service."

title="LinkedIn"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/linkedin.png"

title="LinkedIn" alt="LinkedIn" class="sociable-hovers"

/>

href="mailto:?subject=5%20Minute%20Developer%3A%20%20How%20to%20Build%20a%20Currency%20Converter%20in%205%20Minutes&body=http%3A%2F%2Fxignite.web-services-blog.com%2F2010%2F01%2F5-minute-developer-how-to-build-a-currency-converter-in-5-minutes%2F"

title="E-mail this story to a friend!"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/email_link.png"

title="E-mail this story to a friend!" alt="E-mail this story to

a friend!" class="sociable-hovers" />

href="http://feeds.feedburner.com/~ff/Xignite?a=ulXWyZuE-X0:aBnKreBCqRo:yIl2AUoC8zA"> src="http://feeds.feedburner.com/~ff/Xignite?d=yIl2AUoC8zA"

border="0">

src="http://feeds.feedburner.com/~r/Xignite/~4/ulXWyZuE-X0"

height="1" width="1" />

  • Copyright © Automated Trader Ltd 2013 - The Gateway to Algorithmic and Automated Trading

click here to return to the top of the page