Page 1 of 1
Format telephone numbers
Posted: Mon Jun 20, 2016 8:05 pm
by ecpmiranda
I have a TextBox and need to format.
The telephone number is a string like this "27999999999" and I need to format like this "(27) 99999-9999"
How can I format this TextBox?
Re: Format telephone numbers
Posted: Tue Jun 21, 2016 10:10 am
by HighAley
Hello.
Please, set the Custom Format with next mask:
or you could use next expression:
Code: Select all
{27999999999.ToString("(##) #####-####")}
Thank you.
Re: Format telephone numbers
Posted: Tue Jun 21, 2016 3:34 pm
by ecpmiranda
I tried the first approach, did not work.
The field is string type and value is 99999999999 (eleven digits) two for long distance number and the rest telephone number.
Re: Format telephone numbers
Posted: Tue Jun 21, 2016 5:58 pm
by ecpmiranda
Try changing textformat of telephone fields on the attached report (TELEFONES DE CONTATO)
Re: Format telephone numbers
Posted: Wed Jun 22, 2016 10:23 am
by Alex K.
Hello,
Please try to use the following expression:
Code: Select all
{String.Format("{0:(##) #####-####}", System.Convert.ToInt64(DataSet1.TelefoneResidencialAluno))}
Thank you.
Re: Format telephone numbers
Posted: Wed Jun 22, 2016 9:23 pm
by ecpmiranda
Is the only solution? I will have to check for null values, because not always I have a telephone number at this field.
Re: Format telephone numbers
Posted: Thu Jun 23, 2016 11:00 am
by Alex K.
Hello,
You can add the additional checks on the null values:
Code: Select all
{(DataSet1.TelefoneResidencialAluno == "" ? "" :String.Format("{0:(##) #####-####}", System.Convert.ToInt64(DataSet1.TelefoneResidencialAluno)))}
Thank you.
Re: Format telephone numbers
Posted: Sat Jun 25, 2016 11:58 am
by ecpmiranda
Thanks! Problem solved!
Re: Format telephone numbers
Posted: Sun Jun 26, 2016 6:02 pm
by Andrew
Great!
We are glad to help you!