`
isiqi
  • 浏览: 16707363 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

ASP常用函数

阅读更多
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: <!--at--> 
 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: <!--ay(#8/4/99#--> 
 RESULT: 4 
 
FormatCurrency() 
 FUNCTION: 返回表达式,此表达式已被格式化为货币值  
 SYNTAX: FormatCurrency(Expression [, Digit ][, LeadingDigit ][, Paren ][, 
GroupDigit]]]]) 
 ARGUMENTS: Digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是
计算机的区域设置; LeadingDigit 三态常数,指示是否显示小数值小数点前面的
零。 
 EXAMPLE: <!--ormatCurrency(34.3456--> 
 RESULT: $34.35 
 
FormatDateTime() 
 FUNCTION: 返回表达式,此表达式已被格式化为日期或时间 
 SYNTAX: FormatDateTime(Date, [, NamedFormat]) 
 ARGUMENTS: NamedFormat 指示所使用的日期/时间格式的数值,如果省略,则使用 
vbGeneralDate. 
 EXAMPLE: <!--ormatDateTime("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: <!--ormatNumber(45.324567, 3--> 
 RESULT: 45.325 
 
FormatPercent() 
 FUNCTION: 返回表达式,此表达式已被格式化为尾随有 % 符号的百分比(乘以 
100 )。 (%) 
 SYNTAX: FormatPercent(Expression [, Digit ][, LeadingDigit ][, Paren ][, 
GroupDigit]]]]) 
 ARGUMENTS: 同上. 
 EXAMPLE: <!--ormatPercent(0.45267, 3--> 
 RESULT: 45.267% 
 
Hour() 
 FUNCTION: 以24时返回小时数. 
 SYNTAX: Hour(time) 
 ARGUMENTS: 
 EXAMPLE: <!--our(#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: <!--NT(32.89-->  <!--nt(-3.33-->
 RESULT: 32  -4
 
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: <!--inute(#12:45:32 PM#--> 
 RESULT: 45 
 
Month() 
 FUNCTION: 返回日期. 
 SYNTAX: Month(date) 
 ARGUMENTS: date is any valid date expression. 
 EXAMPLE: <!--onth(#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: <!--onthName(Month(#08/04/99#)--> 
 RESULT: August 
 
Now() 
 FUNCTION: Returns the current system date and time. 
 SYNTAX: Now() 
 ARGUMENTS: None 
 EXAMPLE: <!--o--> 
 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: <!--econd(#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: <!--im--> 
 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: <!--ear(#8/4/99#--> 
 RESULT: 1999
分享到:
评论

相关推荐

    asp常用函数大全 学习asp必备

    对于学习ASP并希望深入掌握其功能的开发者而言,了解并熟练运用ASP中的常用函数是至关重要的。根据给定文件的信息,我们可以提炼出一系列与ASP相关的知识点,涵盖数据库操作、用户信息获取、字符串处理、日期时间...

    经常使用到的ASP常用函数汇总

    ### ASP常用函数详解 在ASP(Active Server Pages)开发中,使用内置函数可以极大地提高工作效率并简化编程过程。本文将详细介绍几个常用的ASP函数及其应用场景,包括`Array()`、`CInt()`、`CreateObject()`、`CStr...

    asp常用函数集合

    ### ASP 常用函数集合解析 在ASP (Active Server Pages) 开发中,自定义函数可以帮助开发者更高效地处理各种需求。以下是对给定文件中的几个自定义函数的详细解析,这些函数覆盖了字符串处理、数组操作以及SQL构建...

    asp常用函数库超级详细版

    这个“ASP常用函数库”文档包含了一系列在ASP编程中常用的函数,涵盖了文件操作、字符串处理、网络信息获取、数据库交互等多个方面。以下是这些函数的一些详细说明: 1. 函数 ID:0001【截字符串】 SubstZFC 函数...

    ASP 常用函数集合

    ASP 常用函数 集合! 汇总

    ASP常用函数库(非系统函数)

    这个“ASP常用函数库”集合了开发者编写的实用函数,可以帮助提高开发效率,解决常见问题。 文档"ASP常用函数库.doc"可能包含以下一些关键知识点: 1. **字符串处理函数**:字符串操作是ASP中常见的任务,如字符串...

    asp常用函数.rar

    这个“asp常用函数.rar”压缩包包含了一些在ASP编程中常用的函数,这些函数可以帮助开发者更高效地处理字符串、数字和数据转换,从而提高开发效率。 1. **字符串处理函数** - `Len()`:返回字符串的长度,这对于...

    ASP常用函数库

    ASP常用函数库,详细介绍了ASP动态服务器页面开发中所使用的各类函数

    ASP常用函数小手册

    以下是对给定文件中提及的一些常用ASP函数的详细解释: 1. **Array()** 函数: - `Array()` 用于创建一个数组,可以包含字符或数字。在提供的代码范例中,`Dim User=Array("张三","李四","王五")` 创建了一个包含3...

    asp常用函数详细说明

    asp常用函数详细说明,几乎所有的ASP函数都在这里

    ASP常用函数集(WORD可打印版)

    本篇主要介绍ASP中常用的日期/时间函数,这些函数允许开发者处理和操作与日期、时间和星期相关的数据。 1. Now 函数: `Now()` 返回当前计算机系统设定的完整日期和时间值,包括年、月、日、时、分、秒和星期。 2...

    ASP 常用函数30 个

    以下是一些ASP常用的函数及其详细说明: 1. **Array()** 函数用于创建一个数组变量。例如: ```vbscript i = Array("1", "2", "3") ``` 这会创建一个包含三个元素的数组,分别是"1"、"2"和"3"。 2. **Cint()**...

    asp常用函数

    本文将深入解析ASP中的一个关键知识点:`Replace`函数,这是一个广泛应用于字符串操作的强大工具。通过理解其工作原理及应用场景,开发者能够更有效地处理文本数据,提升网站的功能性和用户体验。 ### Replace函数...

    常用函数速查(asp)

    ASP(Active Server Pages)是一种微软...在"asp常用函数速查.doc"文档中,你应该能找到更多关于这些函数的详细信息和示例,帮助你在实际项目中更高效地编写代码。记住,掌握这些基本函数是成为ASP开发高手的第一步。

    asp常用函数收集很实用的

    根据提供的ASP代码片段,我们可以总结出以下几个重要的ASP函数知识点: ### ASP函数:判断是否为汉字 `isChinese(para)` 此函数用于判断输入的参数`para`是否全为汉字。 **函数逻辑:** - 首先检查参数是否为空...

    asp 常用函数用法

    Array() FUNCTION: 返回一个数组 SYNTAX: Array(list) ARGUMENTS: 字符,数字均可 EXAMPLE: &lt;&#37; Dim myArray() For i = 1 to 7 Redim Preserve myArray(i) myArray(i) = WeekdayName(i)...

    ASP常用函数集合一般网站程序足够用了

    以下是一些ASP中常用的函数,这些函数对于构建一般的网站程序来说非常实用: 1. **Response对象的Write方法**: - 这个方法用于向客户端发送数据,例如HTML、文本或JavaScript代码。`Response.Write("Hello, World...

    ASP常用函数集合[定义].pdf

    在ASP中,函数是预定义的代码块,用于执行特定任务。以下是一些在ASP中常用的函数及其详细说明: 1. `OpenDB(vdata_url)`: 这个函数用于打开数据库连接,`vdata_url`参数通常包含数据库的连接字符串,如数据库类型...

    ASP常用函数:getpy()

    ### ASP常用函数:getpy()详解 #### 一、概述 在网页开发中,尤其是在中文环境下进行网站或应用程序的开发时,经常会遇到需要处理中文字符的需求。例如,在制作搜索引擎或者中文输入法时,获取中文字符串的拼音首...

Global site tag (gtag.js) - Google Analytics