Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 19 in printed book and digital formats -- plus a one-year subscription (beginning with 20.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 20.3 ('XDC Anywhere')
Instant purchase and download via GumRoad!

FEATURE

Easy Money Entry

Allowing the user maximum flexibility in entering monetary amounts

Issue: 20.3 (May/June 2022)
Author: Tom Baumgartner
Author Bio: Tom is retired and has enjoyed programming in Xojo as a hobby for over 20 years, especially during the Canadian winter when there is only curling and bridge to replace golf, fishing and playing tennis.
Article Description: No description available.
Article Length (in bytes): 17,615
Starting Page Number: 35
Article Number: 20305
Resource File(s):

Download Icon project20305.zip Updated: 2022-05-05 14:11:44

Related Link(s): None

Excerpt of article text...

I have been using Quicken, a popular single-entry financial records application, for over 20 years. I have always thought that the user interface could be improved and I have wanted some retirement planning features. When I retired, I developed a Microsoft Excel spreadsheet for retirement planning that requires transferring information from Quicken at the beginning of each year. Recently, I embarked on a big app development project that will combine the financial records function and the long-term retirement planning function.

Every financial transaction requires entering a monetary value. Obviously that entry becomes a focus for a simple and easy user interface. This article presents my solution for user entry of the transaction amount. An example project is available for download. All the code in the original project for saving the transaction to a database has been removed, but the structure of the code remains so some of the example code will be more complex than necessary.

The user is allowed to enter any of the monetary number formats shown in Figure 1. Note that only the period is used as the decimal point in this example. The code could be modified to allow the comma as a decimal point.

Whether a new entry or an edit of an existing entry the user is presented a DesktopTextField (see API 2.0 sidebar). When the entry is complete (user clicks Save) it is transferred to a DesktopListBox displaying all the entries for the particular account (for example, a credit card account).

Rule one is: users can type into a text field in a huge variety of sequences. The code has to check the user's typing to prevent illegal monetary entries under all of the possible sequences. For example, the user could insert a digit or period into the middle of the already entered number or select a portion of the already entered number to replace with a single digit.

Begin by creating a sub-class of DesktopTextField, called CurrencyTextField. Add a property pboolHavePeriod as Boolean. Add the KeyDown event with the the code of Code Listing #1:

...End of Excerpt. Please purchase the magazine to read the full article.