ASP常用的库函数大全Word格式.docx
- 文档编号:22270928
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:18
- 大小:20.31KB
ASP常用的库函数大全Word格式.docx
《ASP常用的库函数大全Word格式.docx》由会员分享,可在线阅读,更多相关《ASP常用的库函数大全Word格式.docx(18页珍藏版)》请在冰豆网上搜索。
whileisBlankChar
ifmid(str,pos,1)="
"
then
pos=pos+1
elseifmid(str,pos,2)=VBcrlfthen
pos=pos+2
else
isBlankChar=false
endif
wend
ltrimVBcrlf=right(str,len(str)-pos+1)
去掉字符串末尾的连续的回车和空格
functionrtrimVBcrlf(str)
pos=len(str)
whileisBlankCharandpos>
=2
pos=pos-1
elseifmid(str,pos-1,2)=VBcrlfthen
pos=pos-2
rtrimVBcrlf=rtrim(left(str,pos))
判断Email是否有效,返回1表示正确
FunctionisEmail(aEmail)
DimiLocat,v,iLength,i,checkletter
Ifinstr(aEmail,"
@"
)=0Orinstr(aEmail,"
."
)=0Then
isEmail=0
EXITFUNCTION
iLocat=instr(aEmail,"
Ifinstr(iLocat,aEmail,"
)=0Orinstr(iLocat+1,aEmail,"
)>
0Then
Ifleft(aEmail,1)="
Orright(aEmail,1)="
Orleft(aEmail,1)="
Then
v="
1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.@"
iLength=len(aEmail)
Fori=1ToiLength
checkletter=mid(aEmail,i,1)
Ifinstr(v,checkletter)=0Then
Next
isEmail=1
测试用:
显示服务器信息
SubshowServer
Dimname
Response.write"
Tableborder=1bordercolor=lightblueCELLSPACING=0>
foreachnameinrequest.servervariables
Response.write"
tr>
td>
&
name&
/td>
request.servervariables(name)&
br>
/tr>
next
/table>
EndSub
显示Rs结果集以及字段名称
SubshowRs(rs)
DimstrTable,whatever
center>
table>
foreachwhateverinrs.fields
response.write"
b>
&
whatever.name&
/B>
/TD>
strTable="
rs.GetString(,,"
)&
/center>
Response.Write(strTable)
用HTML格式显示文本
Functiontxt2Html(str)
ifisnull(str)then
txt2Html="
exitFunction
endif
str=Replace(str,chr(34),"
str=Replace(str,"
str=Replace(str,chr(13)+chr(10),"
str=Replace(str,chr(9),"
txt2Html=str
显示调试错误信息
SubshowError
DimsErrMsg
sErrMsg=Err.Source&
Err.Description
sErrMsg&
Err.clear
显示文字计数器
SubshowCounter
Dimfs,outfile,filename,count
filename=server.mappath("
count.txt"
Setfs=CreateObject("
Scripting.FileSystemObject"
Iffs.fileExists(filename)Then
Setoutfile=fs.openTextFile(filename,1)
count=outfile.readline
count=count+1
浏览人次:
count&
outfile.close
Setoutfile=fs.CreateTextFile(filename)
outfile.writeline(count)
Setoutfile=fs.openTextFile(filename,8,TRUE)
count=0
ENDIF
setfs=nothing
%>
Array()
FUNCTION:
返回一个数组
SYNTAX:
Array(list)
ARGUMENTS:
字符,数字均可
EXAMPLE:
<
DimmyArray()
Fori=1to7
RedimPreservemyArray(i)
myArray(i)=WeekdayName(i)
RESULT:
建立了一个包含7个元素的数组myArray
myArray("
Sunday"
Monday"
......"
Saturday"
)
CInt()
将一个表达式转化为数字类型
CInt(expression)
任何有效的字符均可
f="
234"
response.writecINT(f)+2
236
转化字符"
为数字"
,如果字符串为空,则返回0值
CreateObject()
建立和返回一个已注册的ACTIVEX组件的实例。
CreateObject(objName)
objName是任何一个有效、已注册的ACTIVEX组件的名字.
Setcon=Server.CreateObject("
ADODB.Connection"
CStr()
转化一个表达式为字符串.
CStr(expression)
expression是任何有效的表达式。
s=3+2
response.write"
Theresultis:
cStr(s)
转化数字“5”为字符“5”。
Date()
返回当前系统日期.
Date()
None.
%=Date%>
8/4/99
DateAdd()
返回一个被改变了的日期。
DateAdd(timeinterval,number,date)
timeintervalisthetimeintervaltoadd;
numberisamountof
timeintervalstoadd;
anddateisthestartingdate.
currentDate=#8/4/99#
newDate=DateAdd("
m"
3,currentDate)
response.writenewDate
currentDate=#12:
34:
45PM#
h"
11/4/99
3:
45PM
="
month"
;
d"
day"
IfcurrentDateisintimeformatthen,
hour"
s"
second"
DateDiff()
返回两个日期之间的差值。
DateDiff(timeinterval,date1,date2[,firstdayofweek][,
firstweekofyear]])
timeinterval表示相隔时间的类型,如“M“表示“月”。
fromDate=#8/4/99#
toDate=#1/1/2000#
Thereare"
_
DateDiff("
fromDate,toDate)&
"
daystomilleniumfrom8/4/99."
从8/4/99到2000年还有150天.
Day()
返回一个月的第几日 .
Day(date)
date是任何有效的日期。
%=Day(#8/4/99#)%>
4
FormatCurrency()
返回表达式,此表达式已被格式化为货币值
FormatCurrency(Expression[,Digit][,LeadingDigit][,Paren][,
GroupDigit]]]])
Digit指示小数点右侧显示位数的数值。
默认值为-1,指示使用的是
计算机的区域设置;
LeadingDigit三态常数,指示是否显示小数值小数点前面的
零。
%=FormatCurrency(34.3456)%>
$34.35
FormatDateTime()
返回表达式,此表达式已被格式化为日期或时间
FormatDateTime(Date,[,NamedFormat])
NamedFormat指示所使用的日期/时间格式的数值,如果省略,则使用
vbGeneralDate.
%=FormatDateTime("
08/4/99"
vbLongDate)%>
Wednesday,August04,1999
FormatNumber()
返回表达式,此表达式已被格式化为数值.
FormatNumber(Expression[,Digit][,LeadingDigit][,Paren][,
计算机的区域设置。
LeadingDigiti指示小数点右侧显示位数的数值。
默认值为-
1,指示使用的是计算机的区域设置。
Paren指示小数点右侧显示位数的数值。
默认
值为-1,指示使用的是计算机的区域设置。
GroupDigiti指示小数点右侧显示位数
的数值。
默认值为-1,指示使用的是计算机的区域设置。
.
%=FormatNumber(45.324567,3)%>
45.325
FormatPercent()
返回表达式,此表达式已被格式化为尾随有%符号的百分比(乘以
100)。
(%)
FormatPercent(Expression[,Digit][,LeadingDigit][,Paren][,
同上.
%=FormatPercent(0.45267,3)%>
45.267%
Hour()
以24时返回小时数.
Hour(time)
%=Hour(#4:
45:
34PM#)%>
16
(Hourhasbeenconvertedto24-hoursystem)
Instr()
返回字符或字符串在另一个字符串中第一次出现的位置.
Instr([start,]strToBeSearched,strSearchFor[,compare])
Start为搜索的起始值,strToBeSearched接受搜索的字符串
strSearchFor要搜索的字符.compare比较方式(详细见ASP常数)
strText="
Thisisatest!
!
pos=Instr(strText,"
a"
response.writepos
9
InstrRev()
同上,只是从字符串的最后一个搜索起
InstrRev([start,]strToBeSearched,strSearchFor[,compare])
pos=InstrRev(strText,"
13
Int()
返回数值类型,不四舍五入,注意取值是不大于它的整数。
Int(number)
%=INT(32.89)%>
<
%=int(-3.33)%>
32 -4
IsArray()
判断一对象是否为数组,返回布尔值 .
IsArray(name)
strTest="
Test!
response.writeIsArray(strTest)
False
IsDate()
判断一对象是否为日期,返回布尔值
IsDate(expression)
expressionisanyvalidexpression.
8/4/99"
response.writeIsDate(strTest)
True
IsEmpty()
判断一对象是否初始化,返回布尔值.
IsEmpty(expression)
Dimi
response.writeIsEmpty(i)
IsNull()
判断一对象是否为空,返回布尔值.
IsNull(expression)
response.writeIsNull(i)
IsNumeric()
判断一对象是否为数字,返回布尔值.
IsNumeric(expression)
i="
345"
response.writeIsNumeric(i)
True
就算数字加了引号,ASP还是认为它是数字。
IsObject()
判断一对象是否为对象,返回布尔值.
IsObject(expression)
response.writeIsObject(con)
LBound()
返回指定数组维的最小可用下标.
Lbound(arrayname[,dimension])
;
dimension指明要返回哪一维下界的整数。
使用1表示第一维,2
表示第二维,以此类推。
如果省略dimension参数,默认值为1.
i=Array("
Tuesday"
Wednesday"
response.writeLBound(i)
0
LCase()
返回字符串的小写形式
Lcase(string)
stringisanyvalidstringexpression.
response.writeLCase(strTest)
thisisatest!
Left()
返回字符串左边第length个字符以前的字符(含第length个字符).
Left(string,length)
response.writeLeft(strTest,3)
Thi
Len()
返回字符串的长度.
Len(string|varName)
response.writeLen(strTest)
15
LTrim()
去掉字符串左边的空格.
LTrim(string)
Thisisatest!
response.writeLTrim(strTest)
Mid()
返回特定长度的字符串(从start开始,长度为length).
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ASP 常用 库函数 大全
![提示](https://static.bdocx.com/images/bang_tan.gif)