网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
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,移动开发
本月文章推荐
.从新浪提取上海天气的vbs.
.一个免费的邮件列表源程序(二).
.用表单来提交sql - 3.
.产生随机密码的函数.
.一个免费的邮件列表源程序(一).
.一个汉字转成拼音的代码.
.利用客户端js实现汉字简体繁体转.
.bbs树形结构的实现方法(一).
.综合的判断用户输入的合法性的函.
.客户端用ASP+rds+VBA参生报表.
.对数据库中的记录用上一条下一条.
.利用ASP实现三个强大功能之一.
.网上“店铺”DIY(2).
.使用XMLHTTP制作域名查询系统.
.调试 ASP 中使用的 Visual Basic.
.使用JScript.NET创建asp.net页面.
.ASP网站远程客户实现EXCEL打印功.
.利用ASP.NET设计FTP文件上传(上).
.用ASP开发一个在线考试程序(六).
.经典的分页完整程序+注释.

ASP中的函数应用方法及应用举例(一)

发表日期:2000-8-25


1.Array()
  FUNCTION: Returns a variant containing an array.
  SYNTAX: Array(list)
  ARGUMENTS: list is a comma-delimited list of values to add to the array.
  EXAMPLE: <%
Dim myArray()
For i = 1 to 7
   Redim Preserve myArray(i)
   myArray(i) = WeekdayName(i)
Next
%>
  RESULT: Creates an Array contains 7 elements:
myArray("Sunday","Monday", ... ... "Saturday")
-------------------------------------
  
2. CInt()
  FUNCTION: Returns an expression that has been converted to an Interget subtype.
  SYNTAX: CInt(expression)
  ARGUMENTS: expression is any valid expression
  EXAMPLE: <%
f = "234"
response.write cINT(f) + 2
%>
  RESULT: 236
Converts string "234" to mathematic value 234.
If f is empty (un-initialized variable), cINT() returns 0.
-------------------------------------
  
3. CreateObject()
  FUNCTION: Creates and returns a reference to ActiveX automation object.
  SYNTAX: CreateObject(objName)
  ARGUMENTS: objName is any valid ActiveX automation object.
  EXAMPLE: <%
Set con = Server.CreateObject("ADODB.Connection")
%>
  RESULT:  
-------------------------------------
  
4. CStr()
  FUNCTION: Returns an expression that has been converted to a variant of subtype String.
  SYNTAX: CStr(expression)
  ARGUMENTS: expression is any valid expression
  EXAMPLE: <%
s = 3 + 2
response.write "The result is: " & cStr(s)
%>
  RESULT: Converts a mathematic value 5 to a string "5".
-------------------------------------
  
5. Date()
  FUNCTION: Returns the current system date.
  SYNTAX: Date()
  ARGUMENTS: None.
  EXAMPLE: <%=Date%>
  RESULT: 8/4/99
-------------------------------------
  
6. DateAdd()
  FUNCTION: Returns a date to which a specific time interval has been added.
  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";
-------------------------------------
  
7. DateDiff()
  FUNCTION: Returns the number of intervals between two dates.
  SYNTAX: DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]])
  ARGUMENTS: timeinterval is the time interval to add; date is a valid date expression; firstdayofweek and
firstweekofyear are optional values to specify the first day of the week and first week of year.
  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: There are 150 days to millenium from 8/4/99.
-------------------------------------
  
8. Day()
  FUNCTION: Returns a whole number representing the day of the month.
  SYNTAX: Day(date)
  ARGUMENTS: date is any valid date expression.
  EXAMPLE: <%=Day(#8/4/99#)%>
  RESULT: 4
-------------------------------------
  
9. FormatCurrency()
  FUNCTION: Returns an expression formatted as a currency value.
  SYNTAX: FormatCurrency(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])
  ARGUMENTS: Expression is a valid numeric expression; Digit is an optional numeric value used to indicate
number of digits to the right of the decimal point; LeadingDigit is an optional tristate value to display
a leading zero; Paren is an optional tristate value used to display parentheses around negative values;
and GroupDigit is an option tristate value used to display a number as specified in the group delimiter
settings of the Control Panel's regional settings.
  EXAMPLE: <%=FormatCurrency(34.3456)%>
  RESULT: $34.35
-------------------------------------
  
10. FormatDateTime()
  FUNCTION: Returns an expression formatted as a date or time.
  SYNTAX: FormatDateTime(Date, [, NamedFormat])
  ARGUMENTS: Date is any valid date expression, and NamedFormat is an optional date/time constant.
  EXAMPLE: <%=FormatDateTime("08/4/99", vbLongDate)%>
  RESULT: Wednesday, August 04, 1999
-------------------------------------
  
10. FormatNumber()
  FUNCTION: Returns an expression formatted as a number.
  SYNTAX: FormatNumber(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])
  ARGUMENTS: Expression is a valid numeric expression; Digit is an optional numeric value used to indicate
number of digits to the right of the decimal point; LeadingDigit is an optional tristate value to display
a leading zero; Paren is an optional tristate value used to display parentheses around negative values;
and GroupDigit is an option tristate value used to display a number as specified in the group delimiter
settings of the Control Panel's regional settings.
  EXAMPLE: <%=FormatNumber(45.324567, 3)%>
  RESULT: 45.325
-------------------------------------
  
11. FormatPercent()
  FUNCTION: Returns an expression formatted as a percent value with a trailing percent (%)
  SYNTAX: FormatPercent(Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit]]]])
  ARGUMENTS: Expression is a valid numeric expression; Digit is an optional numeric value used to indicate
number of digits to the right of the decimal point; LeadingDigit is an optional tristate value to display
a leading zero; Paren is an optional tristate value used to display parentheses around negative values;
and GroupDigit is an option tristate value used to display a number as specified in the group delimiter
settings of the Control Panel's regional settings.
  EXAMPLE: <%=FormatPercent(0.45267, 3)%>
  RESULT: 45.267%
-------------------------------------
  
12. Hour()
  FUNCTION: Returns a whole number representing the hour of the day between 0 and 23.
  SYNTAX: Hour(time)
  ARGUMENTS: time is any valid date/time expression.
  EXAMPLE: <%=Hour(#4:45:34 PM#)%>
  RESULT: 16
(Hour has been converted to 24-hour system)
-------------------------------------
  
13. Instr()
  FUNCTION: Returns the numeric position of the first instance of one string within another.
  SYNTAX: Instr([start, ] strToBeSearched, strSearchFor [, compare])
  ARGUMENTS: start (optional) is the numeric position to start the string search; strToBeSearched is the
string expression to be searched; strSearchFor is the string expression search value; and compare
(optional) is the value indicating the comparison constant.
  EXAMPLE: <%
strText = "This is a test!!"
pos = Instr(strText, "a")
response.write pos
%>
  RESULT: 9
(string "a" is the 9th character in strText)
-------------------------------------
  
14. InstrRev()
  FUNCTION: Returns the numeric position of one string within another starting from the end of the string.
  SYNTAX: InstrRev([start, ] strToBeSearched, strSearchFor [, compare])
  ARGUMENTS: start (optional) is the numeric position to start the string search; strToBeSearched is the
string expression to be searched; strSearchFor is the string expression search value; and compare
(optional) is the value indicating the comparison constant.
  EXAMPLE: <%
strText = "This is a test!!"
pos = InstrRev(strText, "s")
response.write pos
%>
  RESULT: 13
(string "s" is the 13th character of strText if you search from the end of the strText)
-------------------------------------
  
15. Int()
  FUNCTION: Returns the integer portion of a number
  SYNTAX: Int(number)
  ARGUMENTS: number is any valid numeric expression.
  EXAMPLE: <%=INT(32.89)%>
  RESULT: 32
(If cINT() is used instead, the result will be 33)
  
-------------------------------------
16. IsArray()
  FUNCTION: Returns a boolean value indicating whether a variable is an array.
  SYNTAX: IsArray(name)
  ARGUMENTS: name is the variable to be determined.
  EXAMPLE: <%
strTest = "Test!"
response.write IsArray(strTest)
%>
  RESULT: False
-------------------------------------

17. IsDate()
  FUNCTION: Returns a boolean value indicating whether the expression can be converted to a date.
  SYNTAX: IsDate(expression)
  ARGUMENTS: expression is any valid expression.
  EXAMPLE: <%
strTest = "8/4/99"
response.write IsDate(strTest)
%>
  RESULT: True
-------------------------------------
  
18. IsEmpty()
  FUNCTION: Returns a boolean value indicating whether a variable has been initialized.
  SYNTAX: IsEmpty(expression)
  ARGUMENTS: expression is any valid expression.
  EXAMPLE: <%
Dim i
response.write IsEmpty(i)
%>
  RESULT: True
-------------------------------------
  
19. IsNull()
  FUNCTION: Returns a boolean value that indicates whether an expression contains no valid datatype.
  SYNTAX: IsNull(expression)
  ARGUMENTS: expression is any valid expression.
  EXAMPLE: <%
Dim i
response.write IsNull(i)
%>
  RESULT: False
-------------------------------------
  
20. IsNumeric()
  FUNCTION: Returns a boolean value indicating whether an expression can be evaluated as a number.
  SYNTAX: IsNumeric(expression)
  ARGUMENTS: expression is any valid expression.
  EXAMPLE: <%
i = "345"
response.write IsNumeric(i)
%>
  RESULT: True
(Even if there are quotation marks around 345, which indicates datatype of string, IsNumeric() function
will still try to convert a string to numeric value first)
-------------------------------------


上一篇:使用VB编写纯ASP程序 人气:11359
下一篇:ASP中的函数应用方法及应用举例(二) 人气:11313
浏览全部ASP中的函数应用方法及应用举例的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐