PDA

Click to See Complete Forum and Search --> : phone number and postal code formating


MartinLiss
Nov 16th, 1999, 12:40 AM
Add two string fields to the table that contains the country. Store the format string for the phone number in one (in this example I've named it fsPhoneNumber) and the format string for the postal code in the other. (BTW the format string for the phone number is (###)###-#### but I don't know how to easily add the space needed in the postal code format string.) When you know the country use the database format string in the format expression like MsgBox Format(MyPhoneNumber, fsPhoneNumber).

------------------
Marty

[This message has been edited by MartinLiss (edited 11-16-1999).]

JayWms
Nov 16th, 1999, 01:42 AM
You should be able to store the format in the table in its own field and call it for the display.

Lets say you have 2 fields in the table, one called [Number] and the other [Format]

For this example we will use a phone number.
[Number] = "1231231234"
[Format] = "(###)###-####"

Okay since I don't know what Database or what you are using to access it, I will be generic, if you give me an example, I will show you the real thing.

txtNumber.Text = Format(DB.Number, DB.Format)

And there you go...

Here is a non-database version of the same thing...

Dim Number$
Dim FormatPhone$

Dim Display$

Number$ = "1231231234"
FormatPhone$ = "(###)###-####"

Display$ = Format(Number$, FormatPhone$)

MsgBox Display$

Jason

David Laplante
Nov 16th, 1999, 11:56 AM
I have phone numbers and postal codes in a data base stored without any formating. I know you can use FORMAT for a date but I need to display the phone number and postal code in a different format depending on the country selected...

if possible, I would like to keep the format strings in a database and refer to it as i need...

for example: If the record (it's a database app) country field is set to canada I need to format this: 9999999999 to this: (999) 999-9999 and the postal code from this: A9A9A9 to this: A9A 9A9
and so on ... the format string being different for each country..

please help