Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vinay Pagaria
  Where is Vinay Pagaria?
 Kolkata
 India
 Vinay Pagaria
 To: Tariq Mehmood
  Where is Tariq Mehmood?
 BAHAWALPUR
 Pakistan
 Tariq Mehmood
 Tags
Subject: RE: Comma in numeric figure
Thread ID: 188559 Message ID: 188834 # Views: 3 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Tuesday, August 12, 2008 9:34:00 AM         
   


> >
> > Why write code in interactivechange when you can achieve what you are trying simply by putting the INPUTFORMAT in TEXT1 = "99,99,999"
> >
> > As the user types, the comma will automatically show in the manner you desire.
> >
> > Regards,
> > Vinay
> > Cheers for Fox, Folks!
> > My Blog: http://weblogs.foxite.com/vinaypagaria
>
>
> WRONG
>
> When User types 123 then comma appears as 12,3
>
> Draw a textbox and apply inputmask as 99,99,999
>
> Then enter 123 and see where comma is displayed.

Your are correct... VFP writes and formats the number from LEFT TO RIGHT and hence this behaviour. The input format gets corrected only after the lost focus event of the textbox. To get the desired output, the entire coding will have to be done by you in the keypress event.

* Text1.value = 0
* Text1.InputFormat = "99,99,999"
* Text1.Keypress event sample shown below.

LPARAMETERS nKeyCode, nShiftAltCtrl
If Between(nKeyCode,48,57)
	If Len(Transform(This.value))<7
		 This.Value = Val(Transform(This.Value) + Chr(nKeyCode))
		 This.Refresh()
		 This.SelStart = 8
	Endif
	NODEFAULT
Endif


Type 1234567 in the textbox now and see.

However please note that the above is not complete as you shall have to provide coding for backspace, delete etc. and you will also have to take care of mouse clicks somewhere in between the entire textbox.

Vinay
Cheers for Fox, Folks!
My Blog: http://weblogs.foxite.com/vinaypagaria

ENTIRE THREAD

Comma in numeric figure Posted by Tariq mehmood @ 8/10/2008 4:47:34 PM
RE: Comma in numeric figure Posted by Anders Altberg @ 8/10/2008 6:56:12 PM
RE: Comma in numeric figure Posted by Tariq mehmood @ 8/10/2008 7:18:35 PM
RE: Comma in numeric figure Posted by surinder singh @ 8/11/2008 6:46:49 AM
RE: Comma in numeric figure Posted by Anders Altberg @ 8/11/2008 11:08:01 AM
RE: Comma in numeric figure Posted by Tariq mehmood @ 8/11/2008 3:48:05 PM
RE: Comma in numeric figure Posted by Anders Altberg @ 8/11/2008 4:32:37 PM
RE: Comma in numeric figure Posted by Tariq mehmood @ 8/11/2008 8:40:22 PM
RE: Comma in numeric figure Posted by Samir Ibrahim @ 8/12/2008 9:27:12 AM
RE: Comma in numeric figure Posted by Glenn Villar @ 8/12/2008 10:13:21 AM
RE: Comma in numeric figure Posted by Koen Piller @ 8/11/2008 4:44:42 PM
RE: Comma in numeric figure Posted by Vinay Pagaria @ 8/11/2008 5:04:52 PM
RE: Comma in numeric figure Posted by Tariq mehmood @ 8/11/2008 8:20:19 PM
RE: Comma in numeric figure Posted by Vinay Pagaria @ 8/12/2008 9:34:00 AM