Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Phone Numbers??

Status
Not open for further replies.

JasSim

Programmer
Jul 24, 2000
12
US
How can I make a phone number look like a phone number??<br>I query a table in Access and pull phone numbers from it.&nbsp;&nbsp;They are saved in the table as (999) 888-7777 even the input mask is saved.&nbsp;&nbsp;They come out looking like 9998887777.<br><br>How can I change that?<br><br>code I have is:<br>Response.Write &quot;&lt;td class=evenrow&gt;&quot; & querySet(&quot;Pager&quot;) & &quot;&lt;/td&gt;&quot;<br>Response.Write &quot;&lt;/tr&gt;&quot;<br>
 
You might want to create a function to do this since <br>Format()doesn't seem to accept user-defined formats in VBScript. So, here's the sample:<br><br><font color=red><br>&lt;html&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;&lt;/TITLE&gt;<br>&lt;% function formatphone(ph)<br>&nbsp;&nbsp;&nbsp;dim formph,code,threedig,lastdig<br>&nbsp;&nbsp;&nbsp;code = &quot;(&quot; & left(ph,3)& &quot;)&quot;<br>&nbsp;&nbsp;&nbsp;threedig = mid(ph,4,3)& &quot;-&quot;<br>&nbsp;&nbsp;&nbsp;lastdig = right(ph,4)<br>&nbsp;&nbsp;&nbsp;formph = code & threedig & lastdig<br>&nbsp;&nbsp;&nbsp;formatphone = formph<br>&nbsp;&nbsp;&nbsp;end function<br>%&gt;<br><br><br>&lt;script LANGUAGE=JAVASCRIPT&gt;<br><br>&lt;!--<br><br>function&nbsp;&nbsp;_CF_checkgetquestion(_CF_this)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;return true;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br><br>//--&gt;<br><br>&lt;/script&gt;<br><br>&lt;/HEAD&gt;<br>&lt;BODY&gt;<br>&lt;%dim phone<br><br>&nbsp;phone = &quot;7987436056&quot; (it's hardcoded just to test the function, could be for example, rs(&quot;phone&quot;))<br>&nbsp;Response.Write formatphone(phone) <br>&nbsp;<br>%&gt;<br><br>&lt;/BODY&gt;<br>&lt;/HTML&gt;<br></font>
 
This is a correction:<br>&lt;html&gt;<br>&lt;HEAD&gt;<br>&lt;TITLE&gt;&lt;/TITLE&gt;<br>&lt;% function formatphone(ph)<br>&nbsp;&nbsp;&nbsp;dim formph,code,threedig,lastdig<br>&nbsp;&nbsp;&nbsp;code = &quot;(&quot; & left(ph,3)& &quot;)&quot;<br>&nbsp;&nbsp;&nbsp;threedig = mid(ph,4,3)& &quot;-&quot;<br>&nbsp;&nbsp;&nbsp;lastdig = right(ph,4)<br>&nbsp;&nbsp;&nbsp;formph = code & threedig & lastdig<br>&nbsp;&nbsp;&nbsp;formatphone = formph<br>&nbsp;&nbsp;&nbsp;end function<br>%&gt;<br>&lt;/HEAD&gt;<br>&lt;BODY&gt;<br>&lt;%dim phone<br><br>&nbsp;phone = &quot;7987436056&quot; (it's hardcoded just to test the function, could be for example, rs(&quot;phone&quot;))<br>&nbsp;Response.Write formatphone(phone) <br>&nbsp;<br>%&gt;<br><br>&lt;/BODY&gt;<br>&lt;/HTML&gt;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top