欢迎光临
我们一直在努力

ASP函数-ASP教程,ASP应用

建站超值云服务器,限时71元/月

array()

function: 返回一个数组

syntax: array(list)

arguments: 字符,数字均可

example: <%

dim myarray()

for i = 1 to 7

redim preserve myarray(i)

myarray(i) = weekdayname(i)

next

%>

result: 建立了一个包含7个元素的数组myarray

myarray("sunday","monday", … … "saturday")

cint()

function: 将一个表达式转化为数字类型

syntax: cint(expression)

arguments: 任何有效的字符均可

example: <%

f = "234"

response.write cint(f) + 2

%>

result: 236

转化字符"234"为数字"234",如果字符串为空,则返回0值

createobject()

function: 建立和返回一个已注册的activex组件的实例。

syntax: createobject(objname)

arguments: objname 是任何一个有效、已注册的activex组件的名字.

example: <%

set con = server.createobject("adodb.connection")

%>

result:

cstr()

function: 转化一个表达式为字符串.

syntax: cstr(expression)

arguments: expression 是任何有效的表达式。

example: <%

s = 3 + 2

response.write "the result is: " & cstr(s)

%>

result: 转化数字“5”为字符“5”。

date()

function: 返回当前系统日期.

syntax: date()

arguments: none.

example: <%=date%>

result: 8/4/99

dateadd()

function: 返回一个被改变了的日期。

syntax: dateadd(timeinterval,number,date)

arguments: timeinterval is the time interval to add; number is amount of time intervals to add; and date is the starting date.

example: <%

currentdate = #8/4/99#

newdate = dateadd("m",3,currentdate)

response.write newdate

%>

<%

currentdate = #12:34:45 pm#

newdate = dateadd("h",3,currentdate)

response.write newdate

%>

result: 11/4/99

3:34:45 pm

"m" = "month";

"d" = "day";

if currentdate is in time format then,

"h" = "hour";

"s" = "second";

datediff()

function: 返回两个日期之间的差值 。

syntax: datediff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]])

arguments: timeinterval 表示相隔时间的类型,如“m“表示“月”。

example: <%

fromdate = #8/4/99#

todate = #1/1/2000#

response.write "there are " & _

datediff("d",fromdate,todate) & _

" days to millenium from 8/4/99."

%>

result: 从8/4/99 到2000年还有 150 天.

day()

function: 返回一个月的第几日 .

syntax: day(date)

arguments: date 是任何有效的日期。

example: <%=day(#8/4/99#)%>

result: 4

formatcurrency()

function: 返回表达式,此表达式已被格式化为货币值

syntax: formatcurrency(expression [, digit [, leadingdigit [, paren [, groupdigit]]]])

arguments: digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置; leadingdigit 三态常数,指示是否显示小数值小数点前面的零。

example: <%=formatcurrency(34.3456)%>

result: $34.35

formatdatetime()

function: 返回表达式,此表达式已被格式化为日期或时间

syntax: formatdatetime(date, [, namedformat])

arguments: namedformat 指示所使用的日期/时间格式的数值,如果省略,则使用 vbgeneraldate.

example: <%=formatdatetime("08/4/99", vblongdate)%>

result: wednesday, august 04, 1999

formatnumber()

function: 返回表达式,此表达式已被格式化为数值.

syntax: formatnumber(expression [, digit [, leadingdigit [, paren [, groupdigit]]]])

arguments: digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; leadingdigit i指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; paren 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。; groupdigit i指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置。.

example: <%=formatnumber(45.324567, 3)%>

result: 45.325

formatpercent()

function: 返回表达式,此表达式已被格式化为尾随有 % 符号的百分比(乘以 100 )。 (%)

syntax: formatpercent(expression [, digit [, leadingdigit [, paren [, groupdigit]]]])

arguments: 同上.

example: <%=formatpercent(0.45267, 3)%>

result: 45.267%

hour()

function: 以24时返回小时数.

syntax: hour(time)

arguments:

example: <%=hour(#4:45:34 pm#)%>

result: 16

(hour has been converted to 24-hour system)

instr()

function: 返回字符或字符串在另一个字符串中第一次出现的位置.

syntax: instr([start, ] strtobesearched, strsearchfor [, compare])

arguments: start为搜索的起始值,strtobesearched接受搜索的字符串 strsearchfor要搜索的字符.compare比较方式(详细见asp常数)

example: <%

strtext = "this is a test!!"

pos = instr(strtext, "a")

response.write pos

%>

result: 9

instrrev()

function: 同上,只是从字符串的最后一个搜索起

syntax: instrrev([start, ] strtobesearched, strsearchfor [, compare])

arguments: 同上.

example: <%

strtext = "this is a test!!"

pos = instrrev(strtext, "s")

response.write pos

%>

result: 13

int()

function: 返回数值类型,不四舍五入。

syntax: int(number)

arguments:

example: <%=int(32.89)%>

result: 32

isarray()

function: 判断一对象是否为数组,返回布尔值 .

syntax: isarray(name)

arguments:

example: <%

strtest = "test!"

response.write isarray(strtest)

%>

result: false

isdate()

function: 判断一对象是否为日期,返回布尔值

syntax: isdate(expression)

arguments: expression is any valid expression.

example: <%

strtest = "8/4/99"

response.write isdate(strtest)

%>

result: true

isempty()

function: 判断一对象是否初始化,返回布尔值.

syntax: isempty(expression)

arguments:

example: <%

dim i

response.write isempty(i)

%>

result: true

isnull()

function: 判断一对象是否为空,返回布尔值.

syntax: isnull(expression)

arguments:

example: <%

dim i

response.write isnull(i)

%>

result: false

isnumeric()

function: 判断一对象是否为数字,返回布尔值.

syntax: isnumeric(expression)

arguments:

example: <%

i = "345"

response.write isnumeric(i)

%>

result: true

就算数字加了引号,asp还是认为它是数字。

isobject()

function: 判断一对象是否为对象,返回布尔值.

syntax: isobject(expression)

arguments:

example: <%

set con = server.createobject("adodb.connection")

response.write isobject(con)

%>

result: true

lbound()

function: 返回指定数组维的最小可用下标.

syntax: lbound(arrayname [, dimension])

arguments: ; dimension 指明要返回哪一维下界的整数。使用 1 表示第一维,2 表示第二维,以此类推。如果省略 dimension 参数,默认值为 1.

example: <%

i = array("monday","tuesday","wednesday")

response.write lbound(i)

%>

result: 0

lcase()

function: 返回字符串的小写形式

syntax: lcase(string)

arguments: string is any valid string expression.

example: <%

strtest = "this is a test!"

response.write lcase(strtest)

%>

result: this is a test!

left()

function: 返回字符串左边第length个字符以前的字符(含第length个字符).

syntax: left(string, length)

arguments:

example: <%

strtest = "this is a test!"

response.write left(strtest, 3)

%>

result: thi

len()

function: 返回字符串的长度.

syntax: len(string | varname)

arguments:

example: <%

strtest = "this is a test!"

response.write len(strtest)

%>

result: 15

ltrim()

function: 去掉字符串左边的空格.

syntax: ltrim(string)

arguments:

example: <%

strtest = " this is a test!"

response.write ltrim(strtest)

%>

result: this is a test!

mid()

function: 返回特定长度的字符串(从start开始,长度为length).

syntax: mid(string, start [, length])

arguments:

example: <%

strtest = "this is a test! today is monday."

response.write mid(strtest, 17, 5)

%>

result: today

minute()

function: 返回时间的分钏.

syntax: minute(time)

arguments:

example: <%=minute(#12:45:32 pm#)%>

result: 45

month()

function: 返回日期.

syntax: month(date)

arguments: date is any valid date expression.

example: <%=month(#08/04/99#)%>

result: 8

monthname()

function: returns a string identifying the specified month.

syntax: monthname(month, [, abb])

arguments: month is the numeric representation for a given month; abb (optional) is a boolean value used to display month abbreviation. true will display the abbreviated month name and false (default) will not show the abbreviation.

example: <%=monthname(month(#08/04/99#))%>

result: august

now()

function: returns the current system date and time.

syntax: now()

arguments: none

example: <%=now%>

result: 8/4/99 9:30:16 am

replace()

function: returns a string in which a specified sub-string has been replaced with another substring a specified number of times.

syntax: replace(strtobesearched, strsearchfor, strreplacewith [, start [, count [, compare]]])

arguments: strtobesearched is a string expression containing a sub-string to be replaced; strsearchfor is the string expression to search for within strtobesearched; strreplacewith is the string expression to replace sub-string strsearchfor; start (optional) is the numeric character position to begin search; count (optional) is a value indicating the comparision constant.

example: <%

strtest = "this is an apple!"

response.write replace(strtest, "apple", "orange")

%>

result: this is an orange!

right()

function: 返回字符串右边第length个字符以前的字符(含第length个字符).

syntax: right(string, length)

arguments: .

example: <%

strtest = "this is an test!"

response.write right(strtest, 3)

%>

result: st!

rnd()

function: 产生一个随机数.

syntax: rnd [ (number) ]

arguments:

example: <%

randomize()

response.write rnd()

%>

result: 任何一个在0 到 1 之间的数

round()

function: 返回按指定位数进行四舍五入的数值.

syntax: round(expression [, numright])

arguments: numright数字表明小数点右边有多少位进行四舍五入。如果省略,则 round 函数返回整数.

example: <%

i = 32.45678

response.write round(i)

%>

result: 32

rtrim()

function: 去掉字符串右边的字符串.

syntax: rtrim(string)

arguments:

example: <%

strtest = "this is a test!! "

response.write rtrim(strtest)

%>

result: this is a test!!

second()

function: 返回秒.

syntax: second(time)

arguments: .

example: <%=second(#12:34:28 pm#)%>

result: 28

strreverse()

function: 反排一字符串

syntax: strreverse(string)

arguments:

example: <%

strtest = "this is a test!!"

response.write strreverse(strtest)

%>

result: !!tset a si siht

time()

function: 返回系统时间.

syntax: time()

arguments: .

example: <%=time%>

result: 9:58:28 am

trim()

function: 去掉字符串左右的空格.

syntax: trim(string)

arguments: string is any valid string expression.

example: <%

strtest = " this is a test!! "

response.write trim(strtest)

%>

result: this is a test!!

ubound()

function: 返回指定数组维数的最大可用下标>.

syntax: ubound(arrayname [, dimension])

arguments: ; dimension (optional) 指定返回哪一维上界的整数。1 表示第一维,2 表示第二维,以此类推。如果省略 dimension 参数,则默认值为 1.

example: <%

i = array("monday","tuesday","wednesday")

response.write ubound(i)

%>

result: 2

ucase()

function: 返回字符串的大写形式.

syntax: ucase(string)

arguments:

example: <%

strtest = "this is a test!!"

response.write ucase(strtest)

%>

result: this is a test!!

vartype()

function: 返回指示变量子类型的值

syntax: vartype(varname)

arguments:

example: <%

i = 3

response.write vartype(i)

%>

result: 2(数字)详见"asp常数"

weekday()

function: 返回在一周的第几天.

syntax: weekday(date [, firstdayofweek])

arguments: .

example: <%

d = #8/4/99#

response.write weekday(d)

%>

result: 4(星期三)

weekdayname()

function: 返回一周第几天的名字.

syntax: weekdayname(weekday [, abb [, firstdayofweek]])

arguments: abb可选。boolean 值,指明是否缩写表示星期各天的名称。如果省略, 默认值为 false,即不缩写星期各天的名称.firstdayofweek指明星期第一天的数值

example: <%

d = #8/4/99#

response.write weekdayname(weekday(d))

%>

result: wednesday

year()

function: 返回当前的年份.

syntax: year(date)

arguments:

example: <%=year(#8/4/99#)%>

result: 1999

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP函数-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章