I haven't studied your code, but it looks like you are on the right track. You can also accept the whole string as is, and then parse it and replace it in the lostfocus event. My guess is that the data comes so quick that nobody will see any flicker. This code will extract the number:
this.value = Strextract( this.value,'%B','^')
>Assuming that the format described in the following page is accurate:
>
http://stackoverflow.com/questions/2121881/parse-credit-card-input-from-magnetic-stripe>
>... and we assume the first set of digits following the "%B" is the number we want...
>
>Perhaps we could "brute-force" it by using Keypressed event and state machine?
>
>Let's say we've got text box (with no input mask) with the following:
>
>Code the INIT:
>
THIS.ADDPROPERTY("nState",0)
>
>Code in GotFocus event:
>
THIS.nState=0
>
>Code in the KeyPress event:
>
>LPARAMETERS nKeyCode, nShiftAltCtrl
>
>IF m.nKeyCode==13 OR m.nKeyCode==9 THEN
> THIS.nState=0
> RETURN
>ENDIF
>IF m.nKeyCode==15 AND m.nShiftAltCtrl==1 THEN
> THIS.nState=0
> RETURN
>ENDIF
>IF m.nKeyCode==37 AND m.nShiftAltCtrl==1 THEN
> THIS.nState=1
> NODEFAULT
> RETURN
>ENDIF
>IF THIS.nState==1 THEN
> THIS.nState=2
> NODEFAULT
> RETURN
>ENDIF
>IF THIS.nState==2 THEN
> IF BETWEEN(m.nKeyCode,48,57) AND m.nShiftAltCtrl==0 THEN
> * Read Digits
> RETURN
> ENDIF
> * Start discarding input at first non-digit
> THIS.nState=3
> NODEFAULT
>ENDIF
>NODEFAULT
>
>
>In addition, we could set KeyPreview to .T. on the form, then use KeyPress event code at form level to force focus to the text box we've set up when we see "%".
>
>>I see that 54128412 and so forth comes twice. Looks like you will have to read everything into a long string, and parse it, before showing the parsed result.
>>
>>>in notepad also beep twice
>>>the text is very long
>>>%B5412841240001042; WANG HEE LIM ^ 100045400152542;...5412841240001042. and some more....
>>>my text box inputmask = 999999999999999999999999999999999999 to filter number only
>>>
>>>
>>>Does the card reader output the same number twice? Open Notepad and see what you see.
>>>
>>>>Hi all
>>>>in my POS payment form i got 2 text box for 2 credit card number
>>>>but when i swept credit card with magnetic card reader in the first text box it beeps twice
>>>>and both text box have the same credit card number
>>>>how to swept the card number and just enter number in the first text box and leave the second text box blank ?
>>>>thanks....