CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Switching between two type of units

    Hi,

    In my application I have two type of units - english and northamerican style i.e, lbs and Kgs ( for weight, etc.). Is there any easier way to toggle between the two types rather than writing code for each??

    I will appreciate your hints and ideas.
    Thanks.


  2. #2
    Join Date
    Apr 1999
    Location
    Alabama, USA
    Posts
    261

    Re: Switching between two type of units

    You might try something like this: Carry a variable of some type in your program to tell you what unit system you want to work with. Then add a 'conversion factor' to all your calculation routines. Write all your calculation code but replace Units with (Units * Conversion Factor). Then all you have to do is check which unit system you are in and adjust the conversion factor appropriately.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured