Home > .net 3.5, c#, General Development, Microsoft, Visual Studio 2008 > My experience creating my first Mobile 6 application

My experience creating my first Mobile 6 application

April 27, 2008

The past few months, I’ve been busied with looking for a new home.  Unfortunately, with home buying comes specials, taxes, financing rates, and a myriad of other calculations—the house price means nothing.

For example, if a home was 150,000$ with no specials, chances are the payment would be less than a home that’s 135,000$ with 15 years of specials left (~15,000$, or 1000$ per year), at least until that 15 year period is over.

But, walking through models and with an agent—how can you calculate that right off the bat?  My agent has a spiffy little calculator that does it, but can’t figure in Homeowner’s Dues or Specials, just PITI.  Well, I’m a developer—I just needed to develop something!

So began my first venture into creating a Windows Mobile 6 application.  I’ve had my T-Mobile HTC Wing.  It’s not a super fancy “all in one,” but I really like it.  What I liked most, when I purchased it, was that I could develop .NET apps for it—I just never (until now) had a good reason.

Mobile Calculator for WM6

Lessons Learned:

  1. The experience of developing for the Mobile platform (e.g. compact framework) is nearly identical to developing for Windows forms—the only difference is being limited to screen size.
  2. The screen resolution (inspite of what shows up on the emulator) does not mirror how it appears on the PDA—even when using the correct emulator and skin in Visual Studio.  This may be a caveat to my Wing, who knows.

Beyond that, at least for this basic application, everything’s the same.  Drag your text boxes, labels, and other controls onto the form, then add logic into the events.

Things I Need To Work On:

  1. Using multi-form “forms”—how can I popup a box for more information?
  2. How can I add a .config file with the application and read/write to it?
  3. How can I save information and settings?
  4. How do I get applications to show up on the Programs menu?

Easy things to research—just haven’t had time.

Also, for those interested, here’s the mortgage forumla based on the Excel PMT formula and rehashed to be used in .NET.  This calculates PITI, then adds in specials, homeowner’s dues, etc. based on the term of the loan etc.  I’ve bolded the important part.  Spacing and usage of the Math.Pow method is required (since C# doesn’t support the ^ operator).

The 20% check mark calculates a downpayment that ensures avoiding mortgage insurance (which is a TOTAL waste of money since it simply ensures the lender, not you).  CalculateDownPayment() returns 20% of the entered value.

NOTE: I’m sure I could refactor and get fancy—but for something this simple, there’s not a lot of value.  As I add (if I am house shopping THAT long to NEED to) features, I may split things up.

private const int monthsPerYear = 12;

private const int term = 30;


private void Calculate_Click(object sender, EventArgs e)


if (PmiCheckbox.Checked)

                     Down.Text = CalculateDownPayment();


var rate = Convert.ToDouble(Rate.Text);

var monthlyRate = rate / monthsPerYear;

var value = Convert.ToDouble(Value.Text);

var down = Convert.ToDouble(Down.Text);

var taxes = Convert.ToDouble(Taxes.Text);

var insurance = Convert.ToDouble(Insurance.Text);


var principal = value – down;


var principalAndInterest =

(principal * monthlyRate) /

(1 – Math.Pow((monthlyRate + 1),

-(term * monthsPerYear)));


var taxesAndInsurance =

(taxes / monthsPerYear) + (insurance / monthsPerYear);


var subTotal =

principalAndInterest + taxesAndInsurance;


var specials = Convert.ToDouble(Specials.Text);

var homeOwners = Convert.ToDouble(Homeowners.Text);


var additionalCharges =

(specials / monthsPerYear) + (homeOwners / monthsPerYear);


var total =

subTotal + additionalCharges;


Total.Text = string.Format(“T: {0:C}”, total);


To conserve real estate, I put the “Total” down near the Calculate button.

The finished product for the Mortgage Calculator.

The application itself is probably directly out of a CS100 course—basic mathematics, but the fact that it’s on my mobile phone rocks.

To me, getting paid at work to create something is great and fufilling, but having a need, even one as simple as this, and being able to create it from scratch is truly rewarding and reminds me why I love being a developer.


  1. Surur
    April 27, 2008 at 1:46 pm

    Instead of using a config file, writing to the registry may be much simpler.

  2. April 27, 2008 at 7:40 pm

    *grin* See, those are good things to know! While I assumed there was a CU hive to the registry, I’ve not looked into how accessible it is. Thanks! 😀

  3. April 29, 2008 at 6:41 pm

    You should’ve tried to sell this to your real estate agent 😉

  4. April 30, 2008 at 5:39 am

    Haha, they’re all Crackberry users. Crackberrys are Java-based (we use and design for them at work), but the platform is _painful_ compared to .NET.

  5. April 30, 2008 at 2:20 pm

    lol. I have a crackberry pearl. I just use it as a phone as I’m not too fancy when it comes to such things… yet.

  6. August 12, 2008 at 12:53 am

    I have an HTC Touch (Sprint). If you wanna try something out on my phone, let me know. I’m game. 🙂

  7. August 12, 2008 at 6:20 am


    Cool; most of the apps I have at the moment are for when I was buying my house–calculating payments, utilities, estimating costs to offers, etc.

    If anything cool comes up, I’ll post it up. 🙂

  1. No trackbacks yet.
Comments are closed.
%d bloggers like this: