Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Samir Ibrahim
  Where is Samir Ibrahim?
 Chekka
 Lebanon
 Samir Ibrahim
 To: Tariq Mehmood
  Where is Tariq Mehmood?
 BAHAWALPUR
 Pakistan
 Tariq Mehmood
 Tags
Subject: RE: Comma in numeric figure
Thread ID: 188559 Message ID: 188826 # Views: 3 # Ratings: 2
Version: Visual FoxPro 9 Category: Forms
Date: Tuesday, August 12, 2008 9:27:12 AM         
   


> >
> > Could you describe your plan again?
> >
> > -Anders
>
> This is not complicated puzzle.
>
> Text1 has Numeric data type but in property sheet it has no Input mask or format.
>
> If user writes 1234 then comma automatically displayed as 1,234 (before pressing enter)
> If user write 12345 then comma automatically displayed as 12,345 (before pressing enter)
> If user write 123456 then comma automatically displayed as 1,23,456 (before pressing enter)
> If user write 1234567 then comma automatically displayed as 12,34,567 (before pressing enter)
>
> and so on as 12,34,56,789

** put this code in form1.text1.InteractiveChange
lnLength = LEN(ALLTRIM(this.text))-OCCURS(",",this.Text)

IF lnLength <=3
		lcTextNoSpace = ALLTRIM(this.Text)
		lcTextNoComma = STRTRAN(lcTextNoSpace,",","")
		this.Value = LEFT(lcTextNoComma,lnLength)
		KEYBOARD '{END}'
ENDIF

IF lnLength = 4
		lcTextNoSpace = ALLTRIM(this.Text)
		lcTextNoComma = STRTRAN(lcTextNoSpace,",","")
		lcFormattedText = LEFT(lcTextNoComma  ,1) + "," + RIGHT(lcTextNoComma ,3)
		this.Value = lcFormattedText
		KEYBOARD '{END}'
ENDIF
IF lnLength = 5 
		lcTextNoSpace = ALLTRIM(this.Text)
		lcTextNoComma = STRTRAN(lcTextNoSpace,",","")
		lcFormattedText = LEFT(lcTextNoComma ,2) + "," + RIGHT(lcTextNoComma ,3)
		this.Value = lcFormattedText
		KEYBOARD '{END}'
ENDIF
IF lnLength = 6 
		lcTextNoSpace = ALLTRIM(this.Text)
		lcTextNoComma = STRTRAN(lcTextNoSpace,",","")
		lcFormattedText = LEFT(lcTextNoComma ,1) + "," + SUBSTR(lcTextNoComma ,2,2) + "," + RIGHT(lcTextNoComma ,3)
		this.Value = lcFormattedText
		KEYBOARD '{END}'
ENDIF
IF lnLength = 7 
		lcTextNoSpace = ALLTRIM(this.Text)
		lcTextNoComma = STRTRAN(lcTextNoSpace,",","")
		lcFormattedText = LEFT(lcTextNoComma ,2) + "," + SUBSTR(lcTextNoComma ,3,2) + "," + RIGHT(lcTextNoComma ,3)
		this.Value = lcFormattedText
		KEYBOARD '{END}'
ENDIF


you can use DO CASE. but you do it ;)

Samir R. Ibrahim
Good things Take time, Great things happend all at once.

My WebLog
My Website: www.cdcity.org

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