How Much for the Beemer in the Window

How to create a car lease payment calculator for the Pocket PC using .NET Compact Framework

I've learned (the hard way) that knowledge is power when you go to lease cars. For the past couple of years I have been tooling around town in my wife's Turbo Beetle (head ducked down low and trying to look as cool as possible) because we became a one-car family and ditched the more expensive one. We still have thirteen more months left on the lease, and by the time it ends we will have sent in almost 90% of the car's purchase price—for a four-year lease. Looking back on things now, we could have saved ourselves about $70 per month if we'd only gone to the dealership prepared. Having a lease payment calculator that you can take with you to the dealership can be a useful weapon...I mean, tool.

Normally when you walk into a dealership and choose your model and accessories, the salesperson will draw two intersecting lines on a piece of paper (if they're not already pre-printed there) to make four boxes, each of which represents an aspect of the deal: cash down payment, trade-in value, price of the new car, and monthly payment. Each one of these is a way for the salesperson to lead you into a deal. It is very important that you fight for every cent in each of these four boxes, but you'll do best to base your fighting position on fact. Remember, the salesperson (usually) knows what you know. For instance, it won't do you much good to tell them that you can trade your car in down the street for $15,000 when the Kelley Blue Book Web site (http://www.kbb.com) lists its value as $12,000 in excellent condition. The salesperson can use the Blue Book too! To get an edge, you need to know what the salesperson knows—and surprisingly few lease customers do.

Writing a simple .NET CF app

The .NET Compact Framework opened the door for .NET developers to start writing applications for smart devices. I had a Pocket PC sitting in its cradle for months because I never found it necessary to have my entire contact list or calendar on my person (unlike people in other industries, such as sales). When I downloaded the Compact Framework and started writing my first application, I began to realize how useful the dusty device could become. I was already familiar with VB.NET and C#, and deployment was a breeze. That reduced the learning curve enough for me to be productive with it very quickly.

Those who do not own a Pocket PC can also develop applications based on the Compact Framework if they have Visual Studio .NET 2003. It comes with a configurable emulator that allows you to run your application just as if it were on a real device. The emulator's memory size can be jacked up by going to Visual Studio's Options dialog, so you have the potential to run some pretty hefty applications. By making use of SQL CE you can run database applications as well.

To show just how easy it is to write useful applications for mobile devices, we'll create a lease payment calculator for the Pocket PC using Visual Studio .NET 2003. Start a new Smart Device Application project in Visual Studio. Call your application LeaseCalculator. Be sure to choose Pocket PC as your platform and Windows Application as your project type in the wizard that follows.

By default you should have one Windows form in your application called Form1. Change its file name to frmPayment.vb; then use the form's Properties window to change its name to frmPayment.

The next thing we'll need is the calculator engine itself, so add a new Class to your project called Lease.vb. This will be a very simple class and will definitely not contain all the properties and methods necessary to represent a car lease, but we'll encapsulate the lease payment logic in its own class anyway to make it easy to extend its functionality later if you choose. You may also want to provide a different user interface for your payment calculator in the future and having the calculation logic in a class makes it very portable. The properties we'll be creating are by no means intended to be representative of the best way to code but rather just to work. Validations and error-checking have been purposely left out for simplicity's sake.