1. Currency data entry
- Posted by Anando Banerjee <anandobanerjee at rediffmail.com> Mar 07, 2005
- 529 views
Hi, How do I set up a data entry field for currency data with 2 decimal places? Commas, though not mandatory, would be gladly welcomed. EditText with ES_NUMBER allows only numeric digits without decimal points, etc. Thanks. Anando
2. Re: Currency data entry
- Posted by Kenneth Rhodes <wolf_man_jacques at excite.com> Mar 07, 2005
- 506 views
Anando Banerjee wrote: > > Hi, > > How do I set up a data entry field for currency data with 2 decimal places? > Commas, > though not mandatory, would be gladly welcomed. > > EditText with ES_NUMBER allows only numeric digits without decimal points, > etc. > > Thanks. > Anando > There are two generic programs in the archives. One is called "insert periods" and the the other is "insert commas" which may be of help: http://www.rapideuphoria.com/cgi-bin/asearch.exu?gen=on&keywords=insert+periods+commas Ken Rhodes 100% Microsoft Free!
3. Re: Currency data entry
- Posted by Anando Banerjee <anandobanerjee at rediffmail.com> Mar 07, 2005
- 528 views
- Last edited Mar 08, 2005
Thanks Ken, The routines work just fine but my requirement is slightly different. Maybe, I should have mentioned "win32lib" and EditText-type control. What I am looking for is a control that restricts user input to + or -, numeric digits, and a decimal point. My searches in the Archives and EUforum keep coming up with post-entry checks, but it would be pretty undignified if the user can (accidentally) enter alpha characters into a textbox for currency input. My attempts to monitor/control keyboard input with w32Change keep resulting in "the choicest abuses" by ex.err as well as a couple of "illegal function" reprimands by Windows 98SE. Isn't there something along the lines of ES_NUMBER? Anando Kenneth Rhodes wrote: > > Anando Banerjee wrote: > > > > Hi, > > > > How do I set up a data entry field for currency data with 2 decimal places? > > Commas, > > though not mandatory, would be gladly welcomed. > > > > EditText with ES_NUMBER allows only numeric digits without decimal points, > > etc. > > > > Thanks. > > Anando > > > > There are two generic programs in the archives. One is called > "insert periods" > and the the other is "insert commas" > which may be of help: > <a > href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?gen=on&keywords=insert+periods+commas">http://www.rapideuphoria.com/cgi-bin/asearch.exu?gen=on&keywords=insert+periods+commas</a> > > > Ken Rhodes > 100% Microsoft Free! >
4. Re: Currency data entry
- Posted by Jonas Temple <jtemple at yhti.net> Mar 07, 2005
- 504 views
- Last edited Mar 08, 2005
Anando Banerjee wrote: > What I am looking for is a control that restricts user input to + or -, > numeric digits, > and a decimal point. My searches in the Archives and EUforum keep coming up > with post-entry > checks, but it would be pretty undignified if the user can (accidentally) > enter alpha > characters into a textbox for currency input. My attempts to monitor/control > keyboard > input with w32Change keep resulting in "the choicest abuses" by ex.err as well > as a > couple of "illegal function" reprimands by Windows 98SE. > > Isn't there something along the lines of ES_NUMBER? > Anando, To accomplish this, you'll need to add an w32HKeyPress event handler to your program. Then just filter out any non-numeric entry. Here's a snip from a program where I do just that. This example allows for a single text box to be either numeric or character so hopefully it'll help. You'll notice that the routine has logic to handle if the entry can/cannot contain a decimal place and the largest number that can be entered. It doesn't have support for ',' but you can add it very easily. HTH
-------------------------------------------------------------------------------- procedure ScriptValET_onKeyPress (integer self, integer event, sequence params)--params is ( int keyCode, int shift ) sequence entry_text atom minus_sign, decimal entry_text = getText(ScriptValET) -- Allow backspace if params[1] != VK_BACK then -- We won't block any key press for character types -- but for decimal we'll only allow 0-9, '.' and '-' if equal(dlg_data[TYPE], "DEC") then if dlg_data[DECIMAL] and not find(params[1], "0123456789-.") then returnValue(-1) elsif not dlg_data[DECIMAL] and not find(params[1],"0123456789-") then returnValue(-1) end if end if -- Limit length of entry if equal(dlg_data[TYPE],"DEC") then if find('-',entry_text) then minus_sign = 1 else minus_sign = 0 end if if find('.',entry_text) then decimal = 1 else decimal = 0 end if if (dlg_data[DECIMAL] and length(entry_text) = (dlg_data[LENGTH]+minus_sign+decimal)) or (not dlg_data[DECIMAL] and length(entry_text) = dlg_data[LENGTH]) then returnValue(-1) end if elsif length(entry_text) = dlg_data[LENGTH] then returnValue(-1) end if end if end procedure setHandler( ScriptValET, w32HKeyPress, routine_id("ScriptValET_onKeyPress"))
Jonas Temple http://www.yhti.net/~jktemple