Numeric Data Input Mask?

david

Member
Licensed User
Hi Erel,

I feel a little ridiculous asking this question, especially since I know that you are busy with the new release.

On the other hand, I have worked in a number of languages over the years (including early Java), where you could spend literally days trying to figure out how to restrict data in a text box to numeric input with a set number of positions before and after the decimal point.

My question then, is there a numeric mask that can be applied to a textBox (or some other control) that will allow me to create a numeric only data input field on the form. I know I can do it by testing each character, but I thought there might be a more elegant and simpler way of doing this.

Might the answer lie in one of the library dll's?

I have searched the forum, as well as the help files and I did not find any numeric masked data input information.

Please advise.

Thanks again for the great work.

Regards,

David
 

david

Member
Licensed User
Numeric Data Mask

Hi Erel,

Thanks for the quick reply.

Unfortunately, in my current application, screen space is in very short supply, so instead I resorted to the code that follows at the end of this message.

I broke the numeric field into two fields (one for an integer value and one for a decimal value). I ignore all the keys except numbers, escape, backspace, enter, delete, and the left and right arrow keys. That suits my functionality in this particular application. Also, I decided to split the field into integer and decimal with two text boxes, since I will be dealing with an unsophisticated user who will mostly only be entering integer values. I am sure the same procedure can be used with a decimal point in one field.

I know that many, if not most 4th generation languages do not come with a numeric masked field (in which you can specify numeric data, and specify the number of places before and after the decimal point). These fields, which also usually display zeros as the mask, often have to be purchased from third party tool makers. I know this was the case with Borland's Delphi and C++ Builder in the early days.

In any case, I would like to put a numeric masked data input field on my wish list for one of the future Basic4PPC versions.

The code I have constructed is somewhat crude. It suits the purpose now, and I will clean it up later, but for anyone interested here is the code for the integer portion of the input:
=========================
Sub txtQuantityInteger_KeyPress (key)
If key = Chr(27) Then ' The User Pressed The Escape Key
txtQuantityInteger.Text = ""
Return
End If
' Mask Keys Except For Numeric, BackSpace, Delete, Enter (And Arrow Keys By Program Default)
If key <> Chr(48) AND key <> Chr(49) AND key <> Chr(50) AND key <> Chr(51) AND key <> Chr(52) AND key <> Chr(53) AND key <> Chr(54) AND key <> Chr(55) AND key <> Chr(56) AND key <> Chr(57) AND key <> Chr(8) AND key <> Chr(13) AND key <> Chr(127) Then
txtQuantityInteger.IgnoreKey
End If
' Now Check For Length
Len = StrLength(txtQuantityInteger.Text)
If key <> Chr(8) AND Key <> Chr(13) AND Key <> Chr(127) AND Len >= 6 Then
txtQuantityInteger.IgnoreKey
End If
End Sub
============================

I have one final question (at least for the moment).

I am considering writing a rather large sales application using Basic4PPC and Sqlite. It will have many screens and at least seven or eight tables. Am I likely to run into any memory restrictions or other problems with the Basic4PPC compiler, or will my problems be restricted to the total memory available on the device?

Thanks for all your help and timely answers.

Regards,

David
P.S. The development for the new application, will be done in the desktop IDE.
 
Top