SunQuest
 
       .NET
  Home arrow .NET arrow Learning the .NET Framework: Project A Cur...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Learning the .NET Framework: Project A Currency Changer
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 17
    2005-05-26

    Table of Contents:
  • Learning the .NET Framework: Project A Currency Changer
  • Populating the Menu
  • Accepting Data Entry

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Learning the .NET Framework: Project A Currency Changer


    (Page 1 of 3 )

    Have you ever wanted to use the .NET Framework to develop a simple program, such as a currency converter? This article will help you to do just that. It is taken from chapter three of the book Programming the .NET Compact Framework, written by Wei-Meng Lee (O'Reilly, 2005; ISBN: 0596004338).

    Project A: Currency Converter

    This first project shows how to develop a simple currency converter using the .NET Compact Framework’s built-in controls. For simplicity, the sample application is limited to three currencies: U.S. Dollar, CNY (Chinese Yuan), and Singapore Dollar. This application downloads the currency exchange rates from a web service when the application is first used. The application stores the rates in an XML document for subsequent usage.

    Populating the Form with Controls

    In Visual Studio .NET 2003, create a new Smart Device Application (File -> New -> Project, then select Visual Basic Projects -> Smart Device Application). Set the Pocket PC as the target device and select a project type of Windows Application. Your project should open with the default Form1. Before you can add any of the controls, you need to set up two tab forms.

    The application in this project contains one TabControl control, which in turn contains two TabPage controls. The first tab page is called Conversion, while the second is called Set Rates. The TabPage control lets you spread the controls across two pages.

    To set it up, drag the TabControl from the toolbox onto the form. To add the tab page to a TabControl control, select the TabControl, right-click on it, and select Add Tab (see Figure 3-1).

    To change the label of the TabPage, click the tab, select the TabPage (the region just above the tab), right-click on it, and select Properties. Change the Text property of the TabPage to Conversion. Do the same for the second tab page, but set its text to Set Rates. You should enlarge the TabControl so that it fills the form.

    You must add the controls listed in Table 3-1 to this form (see Figures 3-2 and 3-3 for the layout). You’ll also need to add an Options item to the default MainMenu1.


    Figure 3-1.  Add a new TabPage control 

    Table 3-1.  Controls used in the currency converter 

    Control type

    Conversion tab

    Set Rates tab

    Label

    lblResult

    "Base Currency: US$", "Symbol", "Rate"

    TextBox

    txtValue

    txtRate

    ComboBox

    ComboBox1, ComboBox2

    ComboBox3

    Button

    cmd0–cmd9, cmdPt, cmdEq, cmdBackSpace, cmdClear

    cmdUpdate

    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 numbered Button controls to input the amount to convert. The BackSpace button deletes the last character entered, while the Clear button clears the entire line of digits, as displayed


                   Figure 2-3.  Setting up the form (Conversion tab page)


    Figure 3-3.  Setting up the form (Set Rates tab page)

    in the TextBox control. The ListBox control contains a list of previous conversions.

    In the second tab page (Set Rates), the user can set the exchange rate for each currency using the ComboBox and TextBox controls.

    More .NET Articles
    More By O'Reilly Media


     

    Buy this book now. This article is taken from chapter three of the book Programming the .NET Compact Framework, written by Wei-Meng Lee (O'Reilly, 2005; ISBN: 0596004338). Check it out at your favorite bookstore. Buy this book now.

    .NET ARTICLES

    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries
    - Introducing LINQ to SQL Designer using Visua...
    - Beginning LINQ to SQL Using Visual Studio 20...
    - Coding an AjaxPro.NET Based Search Engine fo...
    - Building an AjaxPro.NET Based Search Engine ...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway