numeric field, making commas static (right justify input) 
Author Message
 numeric field, making commas static (right justify input)

Why are the commas all screwed up when entering numeric or currency
data in a text field?  As soon as you tab off the field the commas all
shift to their correct position.

For instance:  When entering one hundred thousand, the user sees
10,000,0.  but as soon as the user tabs off that field, $100,000.00 is
displayed.  We have to close our eyes and count zeros to figure it
out.  Maybe I'm doing something wrong, I don't know.  But the
textinput box does not seem to correctly right justify while the user
is inputting data.  Only when the control loses focus does it format
correctly.

textbox
format = $k
inputmask = 99,999,999.99
datafield is numeric (8)(2)

Can this be overcome?

Thanks,
Louis

------------
Remove the '~' from email address to respond directly
Louis
mrlmz 'AT' apci 'DOT' net



Wed, 21 Feb 2001 03:00:00 GMT  
 numeric field, making commas static (right justify input)
Louis,

Visit the universal thread (www.universalthread.com).  There are some
classes in the libraries there that are for textboxes that handle numeric
data entry.

JimB



Wed, 21 Feb 2001 03:00:00 GMT  
 numeric field, making commas static (right justify input)
VFP is treating the 10,000,0.  as 10 million because your input mask has
99,999,999.99.  Therefore, change the input mask to 999,999,999.99

--Paul

Quote:

>Why are the commas all screwed up when entering numeric or currency
>data in a text field?  As soon as you tab off the field the commas all
>shift to their correct position.

>For instance:  When entering one hundred thousand, the user sees
>10,000,0.  but as soon as the user tabs off that field, $100,000.00 is
>displayed.  We have to close our eyes and count zeros to figure it
>out.  Maybe I'm doing something wrong, I don't know.  But the
>textinput box does not seem to correctly right justify while the user
>is inputting data.  Only when the control loses focus does it format
>correctly.

>textbox
>format = $k
>inputmask = 99,999,999.99
>datafield is numeric (8)(2)

>Can this be overcome?

>Thanks,
>Louis

>------------
>Remove the '~' from email address to respond directly
>Louis
>mrlmz 'AT' apci 'DOT' net



Wed, 21 Feb 2001 03:00:00 GMT  
 numeric field, making commas static (right justify input)
[Word wrap set to 126 for code snip]
Tried that.  Try typing in 1 million with the mask at '999,999,999'.  Result = 100,000,0  <- this is what the user gets to
look at until the field loses focus.  Screwy!  

Pardon my French, but this sucks!

Microsoft can add a property that I can not even use unless I'm in a middle eastern country. <- joke>  But they can't even add
something as simple as numeric input for a numeric/currency textbox.  Go figure.

I put some code in my keypress event of the textbox that seems to work ok for me.  It's a little rough around the edges, but
it is simple and it does just what I need it to.

{=========}
LPARAMETERS nKeyCode, nShiftAltCtrl
LOCAL lcTemp
DO CASE
        CASE nKeyCode >= 48 AND nKeyCode <= 57
                NODEFAULT
                IF This.SelStart <> This.SelLength
                        This.Value = 0
                ENDIF
                m.lcTemp = ALLTRIM(STR(This.Value))
                This.Value = VAL(m.lcTemp + CHR(nKeyCode))
                IF LEN(ALLTRIM(STR(This.Value))) >= Len(CHRTRAN(This.Inputmask,".,",""))
                        KEYBOARD '{TAB}'
                ENDIF
        CASE nKeyCode = 127 && Backspace
                NODEFAULT
                IF This.SelStart <> This.SelLength
                        This.Value = 0
                ELSE
                        m.lcTemp = ALLTRIM(Str(This.Value))
                        This.Value = VAL(SubStr(m.lcTemp,1,(Len(m.lcTemp)-1)))
                ENDIF          
                IF LEN(ALLTRIM(STR(This.Value))) >= Len(CHRTRAN(This.Inputmask,".,",""))
                        KEYBOARD '{TAB}'
                ENDIF
        CASE nKeyCode = 43 && '+'
                NODEFAULT
                IF This.Value < 0 && Hmmm, Must be negative
                        This.value = This.Value * -1  && Make it Positive
                ENDIF
        CASE nKeyCode = 45 && '-'
                NODEFAULT
                IF This.Value > 0  && Must be positive
                        This.value = This.Value * -1  && Make it Negative
                ENDIF
ENDCASE
{=========}

Hope this can help somebody else too,
Louis

Quote:

>VFP is treating the 10,000,0.  as 10 million because your input mask has
>99,999,999.99.  Therefore, change the input mask to 999,999,999.99

>--Paul

------------
Remove the '~' from email address to respond directly
Louis
mrlmz 'AT' apci 'DOT' net


Sat, 24 Feb 2001 03:00:00 GMT  
 numeric field, making commas static (right justify input)
Dick,

Try inserting an R into the Format property.

--
Brett Slattery

Quote:

>[Word wrap set to 126 for code snip]
>Tried that.  Try typing in 1 million with the mask at '999,999,999'.

Result = 100,000,0  <- this is what the user gets to
Quote:
>look at until the field loses focus.  Screwy!

>Pardon my French, but this sucks!

>Microsoft can add a property that I can not even use unless I'm in a middle

eastern country. <- joke>  But they can't even add
Quote:
>something as simple as numeric input for a numeric/currency textbox.  Go
figure.

>I put some code in my keypress event of the textbox that seems to work ok

for me.  It's a little rough around the edges, but
Quote:
>it is simple and it does just what I need it to.

>{=========}
>LPARAMETERS nKeyCode, nShiftAltCtrl
>LOCAL lcTemp
>DO CASE
> CASE nKeyCode >= 48 AND nKeyCode <= 57
> NODEFAULT
> IF This.SelStart <> This.SelLength
> This.Value = 0
> ENDIF
> m.lcTemp = ALLTRIM(STR(This.Value))
> This.Value = VAL(m.lcTemp + CHR(nKeyCode))
> IF LEN(ALLTRIM(STR(This.Value))) >= Len(CHRTRAN(This.Inputmask,".,",""))
> KEYBOARD '{TAB}'
> ENDIF
> CASE nKeyCode = 127 && Backspace
> NODEFAULT
> IF This.SelStart <> This.SelLength
> This.Value = 0
> ELSE
> m.lcTemp = ALLTRIM(Str(This.Value))
> This.Value = VAL(SubStr(m.lcTemp,1,(Len(m.lcTemp)-1)))
> ENDIF
> IF LEN(ALLTRIM(STR(This.Value))) >= Len(CHRTRAN(This.Inputmask,".,",""))
> KEYBOARD '{TAB}'
> ENDIF
> CASE nKeyCode = 43 && '+'
> NODEFAULT
> IF This.Value < 0 && Hmmm, Must be negative
> This.value = This.Value * -1  && Make it Positive
> ENDIF
> CASE nKeyCode = 45 && '-'
> NODEFAULT
> IF This.Value > 0  && Must be positive
> This.value = This.Value * -1  && Make it Negative
> ENDIF
>ENDCASE
>{=========}

>Hope this can help somebody else too,
>Louis

>On Sat, 5 Sep 1998 06:25:43 -0700 , "Paul Borowicz"

>>VFP is treating the 10,000,0.  as 10 million because your input mask has
>>99,999,999.99.  Therefore, change the input mask to 999,999,999.99

>>--Paul

>------------
>Remove the '~' from email address to respond directly
>Louis
>mrlmz 'AT' apci 'DOT' net



Sat, 24 Feb 2001 03:00:00 GMT  
 numeric field, making commas static (right justify input)


Quote:
>Dick,

>Try inserting an R into the Format property.

I wish it were that easy!

------------
Remove the '~' from email address to respond directly
Louis
mrlmz 'AT' apci 'DOT' net



Mon, 05 Mar 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Commas in Numeric fields

2. No comma as thousands separator in numeric fields

3. numeric input fields

4. Right-Justify SAY?

5. Right justified auto-trimming??

6. How to right justify menu bars in vfp6 ?

7. Right Justify Screen Font?

8. Report Form - Left and Right Justify

9. Right justify column in ListBox

10. Need commas in numeric text box

11. Commas in Numeric fie

12. Comma separators for Numeric data in reports

 

 
Powered by phpBB® Forum Software