Browse DevX
Sign up for e-mail newsletters from DevX


Develop a Currency Converter in the .NET Compact Framework

Smart devices require smart applications and in this first of a three-part series on building applications in the .NET Compact Framework, you'll learn how to build one that lets users accurately convert foreign currencies on the fly.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

he best way to learn how to use the various controls in the .NET Compact Framework (CF) is to actually use them. So starting with this article, I will demonstrate a few techniques you can use to develop applications for Pocket PC devices using Visual Studio .NET 2003.

In this first part of the series, I will show how you can develop a simple currency converter using .NET CF's built-in controls. To do this, I will develop a Pocket PC application that allows a user to convert currencies from one country to another. For the sake of simplification, the sample application is limited to three currencies: U.S., RMB (Renminbi, Chinese currency), and Singapore.

Populating the Form with Controls
In Visual Studio.NET 2003, create a new Smart Device Application (Microsoft's term for a mobile application that runs on the Pocket PC platform as well as on Windows CE .NET). Your project should open with the default Form1 ready for input. Populate it with the controls as shown in Figure 1, beginning with the "Conversion" TabPage on the right. The controls used in this example are:

Figure 1. Setting Up the Form. Populate the default Form1 with the various controls you'll need on each of two different TabPages.
  • Label
  • Textbox
  • ComboBox
  • Button
  • MenuItem
  • TabControl
  • ListBox

The first Tab page ("Conversion") contains two ComboBox controls for the user to select the currencies to convert. Once the currencies are selected, the user can click on the Button controls to input the amount to convert. The BackSpace button is to delete the last character entered while the Clear button clears the entire line of digits as displayed in the TextBox control. The ListBox control contains a list of previous conversions.

Figure 2. Clear History. Adding the MenuItem control to the MainMenu to allow the user to start the application anew.
In the second tab page ("Set Rates"), the user can set the exchange rate for each currency using the ComboBox and TextBox controls.

Besides adding the various controls, also add a MenuItem control to the MainMenu control, as shown in Figure 2. When the user selects the Clear History menu item, it clears the ListBox control in the first tab page.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date