dh8324

I'm a pretty new user to VSS and I'm displaying a simple phone list. The phone# field is stored as 14 alphanumberic characters that I want to display as "(888) 999-9999 x.0000"

The current expression is:

=Fields!pphonenumber.Value)

How can I format this properly



Re: Visual Studio Report Controls simple phone number format for vss 2005

Robert Bruckner MSFT

One way of doing this is to use regular expressions:

Code Block

=System.Text.RegularExpressions.Regex.Replace(Fields!phone.Value, "(\d{3})(\d{3})(\d{4})(\d{4})", "($1) $2-$3 x.$4")

-- Robert






Re: Visual Studio Report Controls simple phone number format for vss 2005

dh8324

Thank you -- I'd never have figured out the code on my own, but I do understand it and greatly appreciate your help.

However, I'm now dealing with variations in the data:

1) all 14 characters saved in the field <your code works perfectly>

2) last 4 characters (ie. extension#) are saved as zeros <code works, but I would rather they not display "x. 0000">

3) only 10 characters saved in the field (last 4 digits are blank) <code ignores the formatting altogether>

I tried to use something like an "If...then..." to differentiate the formatting, but I'm obviously too old school - how would you modify your formatting code to accomodate these two variations