how to extract data from AD with VBS, and modify the output by adding spaces, brackets and a dash

hi

i need a sub routine that will read a telephone number from AD and then modify the number by inserting spaces, brackets and dashes into the final output.
the final input is then used in our signature script.
script is working perfectly well i just need to make this small modification.

i think it would fairly simple to do but my vbs skills arent there yet... so im not really sure where to start and what commands i should be looking at.

so to sum things up

as you can see from this image, the phone number comes in the format +xxxxxxxxxxxx
Phone Number
i need this sub routine to modify the number into the following format

+xx (xx) xxxx-xxxx

once the sub has created this into a final output it will then be called by another Sub and entered into the section of the script that creates the signature.

the line in the script that will call on this is

SigFileStream.WriteLine " T " + g_objldapuser.telephoneNumber + " | " +" M " + g_objldapuser.mobile + " | " + " F +xx xxxxxxxx "

Open in new window


id like to replace g_objldapuser.telephoneNumber with the final formatted output from the sub routine so it looks something like this.


SigFileStream.WriteLine " T " + sFormattedPhone + " | " +" M " + g_objldapuser.mobile + " | " + " F +xx xxxxxxxx

Open in new window



i hope this makes sense...  does anybody have a script that does something like this?
or if you could guide me in the right direction that would be great..

please let me know if you need any more info.


cheers
BakerSydAsked:
Who is Participating?
 
RobSampsonConnect With a Mentor Commented:
Hi, this should work for you.

Regards,

Rob.

sFormattedPhone = g_objldapuser.telephoneNumber
sFormattedPhone = Left(sFormattedPhone, 3) & " (" & Mid(sFormattedPhone, 4, 2) & ") " & Mid(sFormattedPhone, 6, 4) & "-" & Right(sFormattedPhone, 4)
SigFileStream.WriteLine " T " + sFormattedPhone + " | " +" M " + g_objldapuser.mobile + " | " + " F +xx xxxxxxxx "

Open in new window

0
 
BakerSydAuthor Commented:
fantastic... does exactly what i need

thanks Rob!
0
 
RobSampsonCommented:
No problem. You had already done the legwork so my part was easy ;-)

Thanks for the grade.

Rob.
0
All Courses

From novice to tech pro — start learning today.