
I have a problem in the numeric tget class
I have to insert 5 discounts example 12.90% I wish have 12,9 %
the fields on archive is 6 digit and 2 decimal
the problem is that the customer wants to insert the data quickly and finds it difficult
if he inserts 12345 automatically the get puts it correctly i.e. 123.45%
if instead he has to insert 10.9% he cannot insert it i.e. if he presses the point or comma after 10
the get goes to the next get
If I press "." or "," the get goes to the next get
I tried to check the digits with aGet[1]:bChange := {|nKey|(Chr(nKey)$"0123456789.")}
or chech the key with aGet[1]:bKeyDown := { | nKey |MyKeyHandler( nKey, @nSconto1 ) }
I tried with picture "@EZ 999,99 %" and "@E ###,## %"
this is the test
Code: Select all | Expand
#include "fivewin.ch"
#include 'constant.ch'
#define DLG_nColorDlg RGB(245,245,235)
FUNCTION Main()
local oDlg
local nRow:= 10,nCol:=10
local nBottom:= 9
local nRight := 75
local nWd := Max( nRight * DLG_CHARPIX_W, 180 )
local nHt := nBottom * DLG_CHARPIX_H
local oFont,oBold
local oSay:=array(1)
local aGet:=array(5)
local cPicture:= "@EZ 999,99 %" //"@E ###,## %"
local nSizeGetSconto := 60
local nSconto1 := 0,;
nSconto2 := 0,;
nSconto3 := 0,;
nSconto4 := 0,;
nSconto5 := 0
oFont := TFont():New( "Arial", 0, -11 )
oBold := TFont():New( "Arial", 0, -11,,.t. )
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
FONT oFont TITLE "test get numerico %" COLOR CLR_BLACK, DLG_nColorDlg ;
STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
WS_MINIMIZEBOX)
@ nRow, nCol SAY oSay[1] PROMPT "Sconto %:" OF oDlg SIZE 75, 18 PIXEL FONT oFont TRANSPARENT
nCol+=110
@ nRow, nCol GET aGet[1] VAR nSconto1 SIZE nSizeGetSconto, 18 PIXEL RIGHT;
PICTURE cPicture;
OF oDlg
aGet[1]:bChange := {|nKey|(Chr(nKey)$"0123456789.")}
//aGet[1]:bKeyDown := { | nKey |MyKeyHandler( nKey, @nSconto1 ) }
nCol+=78
@ nRow, nCol GET aGet[2] VAR nSconto2 SIZE nSizeGetSconto, 18 PIXEL RIGHT;
PICTURE cPicture;
OF oDlg
nCol+=78
@ nRow, nCol GET aGet[3] VAR nSconto3 SIZE nSizeGetSconto, 18 PIXEL RIGHT;
PICTURE cPicture;
OF oDlg
nCol+=78
@ nRow, nCol GET aGet[4] VAR nSconto4 SIZE nSizeGetSconto, 18 PIXEL RIGHT;
PICTURE cPicture;
OF oDlg
nCol+=78
@ nRow, nCol GET aGet[5] VAR nSconto5 SIZE nSizeGetSconto, 18 PIXEL RIGHT;
PICTURE cPicture;
OF oDlg
// Bottone di conferma
@ 90, 100 BUTTON "OK" SIZE 80, 30 PIXEL ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
RETURN NIL
FUNCTION MyKeyHandler( nKey, nVar )
LOCAL cKey := Chr(nKey)
LOCAL cVal
IF cKey == "," .OR. cKey == "."
cVal := LTrim(Str(nVar, 10, 2))
IF "." $ cVal .OR. "," $ cVal
RETURN 0
ENDIF
cVal += ","
nVar := Val( StrTran(cVal, ",", ".") )
RETURN 0
ENDIF
RETURN nKey
any solution pls ?