动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ ASP技巧 ]的信息



本月文章推荐
.如何增强ASP程序性能(4).
.计算ASP页面的载入时间.
.asp模块化分页制作详解.
.asp实现批量录入数据的实现.
.Windows 2003下不注册组件用ASP发.
.批量判断域名是否被注册程序代码.
.用ASP+DLL实现WEB方式修改服务器.
.Microsoft IIS 真的如此「不安全.
.防止网站内容被人小偷和采集的AS.
.使用ASP建立Http组件.
.用SOAP和ASP进行服务器端更新.
.让Session对象在不同域名下实现共.
.利用ASP技术实现文件直接上传功能.
.URL编码与SQL注入.
.不用数据源打开数据库(DSNless .
.瞒天过海html文件技术一瞥.
.如何判断conn.Execute成功 或失败.
.在WAP网站上建立反馈表单.
.Microsoft SQL Server 7.0安全问.
.如何增强ASP程序性能(3).

用ASP实现号码转换

发表日期:1999-5-6 |


<%
'***** BEGIN FUNCTION AREA *****

' Formats a given 10 digit number into a nice looking phone number
' Example: given strNumber of 8005551212 you get (800) 555-1212
Function FormatPhoneNumber(strNumber)
Dim strInput ' String to hold our entered number
Dim strTemp ' Temporary string to hold our working text
Dim strCurrentChar ' Var for storing each character for eval.
Dim I ' Looping var

' Uppercase all characters for consistency
strInput = UCase(strNumber)

' To be able to handle some pretty bad formatting we strip out
' all characters except for chars A to Z and digits 0 to 9
' before proceeding. I left in the chars for stupid slogan
' numbers like 1-800-GET-CASH etc...
For I = 1 To Len(strInput)
strCurrentChar = Mid(strInput, I, 1)
' Numbers (0 to 9)
If Asc("0") <= Asc(strCurrentChar) And Asc(strCurrentChar) <= Asc("9") Then
strTemp = strTemp & strCurrentChar
End If
' Upper Case Chars (A to Z)
If Asc("A") <= Asc(strCurrentChar) And Asc(strCurrentChar) <= Asc("Z") Then
strTemp = strTemp & strCurrentChar
End If
Next 'I

' Swap strTemp back to strInput for next set of validation
' I also clear strTemp just for good measure!
strInput = strTemp
strTemp = ""

' Remove leading 1 if applicable
If Len(strInput) = 11 And Left(strInput, 1) = "1" Then
strInput = Right(strInput, 10)
End If

' Error catch to make sure strInput is proper length now that
' we've finished manipulating it.
If Not Len(strInput) = 10 Then
' Handle errors as you see fit. This script raises a real
' error so you can handle it like any other runtime error,
' but you could also pass an error back via the function's
' return value or just display a message... your choice!
Err.Raise 1, "FormatPhoneNumber function", _
"The phone number to be formatted must be a valid 10 digit US phone number!"

' Two alternative error techniques!
'Response.Write "<B>The phone number to be formatted must be a valid phone number!</B>"
'Response.End

' Note if you use this you'll also need to check for
' this below so you don't overwrite it!
'strTemp = "<B>The phone number to be formatted must be a valid phone number!</B>"
End If

' If an error occurred then the rest of this won't get processed!

' Build the output string formatted to our liking!
' (xxx) xxx-xxxx
strTemp = "(" ' "("
strTemp = strTemp & Left(strInput, 3) ' Area code
strTemp = strTemp & ") " ' ") "
strTemp = strTemp & Mid(strInput, 4, 3) ' Exchange
strTemp = strTemp & "-" ' "-"
strTemp = strTemp & Right(strInput, 4) ' 4 digit part

' Set return value
FormatPhoneNumber = strTemp
End Function

'***** END FUNCTION AREA *****
%>


<%' Runtime Code
Dim strNumberToFormat ' The phone number we pass to the function


' Retrieve the requested number or set it to the default
If Request.QueryString("phone_number") <> "" Then
strNumberToFormat = Request.QueryString("phone_number")
Else
strNumberToFormat = "1-800-555-1212"
End If

' We need to turn this on if we want to trap errors.
' Otherwise the script would generate an error if the input
' number wasn't correct.
On Error Resume Next
%>

<TABLE BORDER="1">
<TR>
<TD>Phone number before formatting:</TD>
<TD><%= strNumberToFormat %></TD>
</TR>
<TR>
<TD>Phone number after formatting:</TD>
<TD>
<%
' Call the function and output the results
Response.Write FormatPhoneNumber(strNumberToFormat)

' Check for an error and display the message if one occurred
If Err.number Then Response.Write Err.description
%>
</TD>
</TR>
</TABLE>

<FORM ACTION="39.asp" METHOD="get">
Phone number to format: <INPUT TYPE="text" NAME="phone_number" VALUE="<%= strNumberToFormat %>">
<INPUT type="submit" value="Submit">
</FORM> 
上一篇:用ASP进行网络打印功能 人气:10091
下一篇:如何用ASP创建日志文件 人气:12692
浏览全部号码转换的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-7-23 Menalto Gallery v2.3 Rc1 多国语
2008-7-23 深度学习网址导航系统 v2.6.1
2008-7-23 因特达crm2008客户关系管理系统
2008-7-23 60度 CMS v1.0 Build 080723
2008-7-23 幻影动漫网视频系统(Ppdong) v1.
2008-7-23 好易祝福墙 2008
2008-7-23 APJE私服发布系统 v2.0 PHP版
2008-7-23 毕业论文在线指导系统源码
2008-7-23 Jacky法律在线网站源码
2008-7-19 UltraEdit 简体中文增强版 14.10
2008-7-19 CentOS 5.2 i386 LiveCD
2008-7-19 Snapture多功能相机 v1.4
2008-7-19 iAcces中文输入法 v1.0Build016
2008-7-19 Cookbook烹饪秘籍 v2.5
2008-7-19 苹果专用DVD转换工具 v1.1.59汉化
2008-7-19 Modem修复软件ZiPhone修改版04.0
2008-7-19 AgileMessenger即时通讯工具美化
2008-7-19 Sketches画图软件 v0.7b6破解版


  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵