Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Dale Dedoroy
  Where is Dale Dedoroy?
 Bacolod City, Negros Occidental
 Philippines
 Dale Dedoroy
 To: Bernard Bout
  Where is Bernard Bout?
 Brisbane
 Australia
 Bernard Bout
 Tags
Subject: RE: Parse Phone Number
Thread ID: 79002 Message ID: 79006 # Views: 4 # Ratings: 1
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Wednesday, October 12, 2005 5:30:12 AM         
   


> > Hello All!
> >
> > I have a database of 2,000 records and the field in question is a character field with a phone number in it (format: (555) 555 - 5555)
> >
> > I am going to create another field that will house the numeric parts of the number; however, I do not remember how to extract the number portions from the original field.
> >
> > I recall that each character/number has a value assigned to it. And something of the sort that with an FOR...ENDFOR statement that should verify the value of the number and skip it if it is that particular value.
> >
> > Of course unless someone has an easy way! Any help would be appreciated!!
> >
> > Nic

>
> How about :
>
>
bb="(555) 999 - 44332"
> nNumber = VAL(STRTRAN(STRTRAN(STRTRAN(STRTRAN(bb,"(",""),")",""),"-","")," ",""))


A shorter approach to Bernard's is to use the ChrTran() function, like:

ctelno = "(555) 999 - 44332"

?int(val(chrtran(ctelno,'()- ','')))

I added the int() function because val() returns decimal value depending upon your SET DECIMALS TO setting.

HTH.

Dale

ENTIRE THREAD

Parse Phone Number Posted by Nic Cross @ 10/12/2005 4:41:36 AM
RE: Parse Phone Number Posted by Bernard Bout @ 10/12/2005 5:22:13 AM
RE: Parse Phone Number Posted by Dale Dedoroy @ 10/12/2005 5:30:12 AM
RE: Parse Phone Number Posted by Andy Kramek @ 10/12/2005 12:28:34 PM
RE: Parse Phone Number Posted by Hans de Groot @ 10/13/2005 5:44:47 PM