Quick Entry 
Using shortcuts for lightning fast number data entry
Last Updated 28th Feb 1998
 

    I recently came across a very ingenious way of facilitating data entry of numbers especially large ones. The technique allows the user to enter numbers using shortcuts like-

So, to enter a figure like 2,340,000 (Two Million, three hundred and forty lakhs) the user has to just type in 2.34m and tab out. This is shown in the figure below-
 
  

Some of the obvious advantages of providing such a means of data entry are-

  1. Data entry is very fast
  2. Data entry is accurate( no more - 'oops I forgot that zero')
  3. Data entry is more 'natural' for the user. For example, the above technique is being used for a Foreign Exchange software and the users find it very natural to enter numbers in the same manner that they express them verbally. This idea can be easily extended to include other commonly used units like 'Dozens'.
 

How To

This technique makes use of the ItemError event. For the column/s for which you wish to provide such a facility specify the edit style as 'Edit' (not EditMask'). When the user types in a figure with a shortcut the ItemError event will be fired since a character is not valid data for a numeric field. The script in ItemError checks for the column name and for the desired column/s call the f_eval_amt() function to interpret and evaluate the shortcuts. The f_eval_amt() function checks for valid shortcuts and returns the evaluated amount. This amount is set for the field and the focus is allowed to change.

The code for ItemError and f_eval_amt() is shown below-
 
ItemError Event 

String Str_Col 
Str_Col = dwo.name 
If Str_Col = 'deal_amount' Then 
    Decimal Dec_UnitPrice 
    Integer Int_RetVal 
 
    Int_RetVal = f_eval_amt(data, Dec_UnitPrice) 
 
    If Int_RetVal = -1 Then 
        //The user input a invalid number, so do the normal 
        //error handling... 
        Return 0 
    Else 
        This.SetItem(row, Str_Col, Dec_UnitPrice) 
        Return 3 
    End If 
End If

 
 
global function integer f_eval_amt (string astr_amt, ref decimal adec_amt);

/////////////////////////////////////////////////////////////////////// 
//[Jiggy 28/02/1998] 
//[NAME] 
//   f_val_amt 
// 
//[INPUT] 
// aStr_Amt  - The string specifying the number using shortcuts 
// aDec_Amt  - [By Ref] Evaluation of aStr_Amt 
// 
//[RETURNS] 
// 1    - Valid string 
// -1    - Invalid String 
// 
//[DESCRIPTION] 
// Evaluates numbers specified using shortcuts 
// Supported shortcuts - 
// M - Million (1,000,000) 
// L - Lakh  (100,000) 
// T - Thousand (1,000) 
// H - Hundred (100) 
/////////////////////////////////////////////////////////////////////// 
 

String Str_ShortCut, Str_Number 
Dec  Dec_Number 

//Check for a valid string 
If IsNull(aStr_Amt) Or Len(aStr_Amt) < 1 Then 
 SetNull(aDec_Amt) 
 Return -1 
End If 

//The passed string should end with a valid shortcut 
Str_ShortCut = Upper(Right(aStr_Amt, 1)) 

If Str_ShortCut <> 'M' And & 
 Str_ShortCut <> 'L' And & 
 Str_ShortCut <> 'T' And & 
 Str_ShortCut <> 'H' Then 
 
 SetNull(aDec_Amt) 
 Return -1 
End If 
 
//Get a valid number from the left of the short. If there is 
//none then assume 1 
If Len(aStr_Amt) > 1 Then 
 Str_Number = Left(aStr_Amt, Len(aStr_Amt) - 1) 
Else 
 Str_Number = "1" 
End If 
 
 
If Not IsNumber(Str_Number) Then 
 SetNull(aDec_Amt) 
 Return -1 
End IF 

Dec_Number = Dec(Str_Number) 
 
//Evaluate 
Choose Case Str_ShortCut 
 Case 'M' 
  aDec_Amt = Dec_Number * 1000000 
 Case 'L' 
  aDec_Amt = Dec_Number * 100000 
 Case 'T' 
  aDec_Amt = Dec_Number * 1000 
 Case 'H' 
  aDec_Amt = Dec_Number * 100 
End Choose 

Return 1 
end function 
 

 

Credits

    I haven't been able to find out who conceived this technique. It was probably an ex-employee who was working on this project but no one seems to remember who!

Back to my HomePage
1