动态网站制作指南



当前位置 > 网站建设学院 > 网络编程 > ASP实例 Rss
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket

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)
-------------------------------------


关注此文的读者还看过:
·2012-5-21 15:43:32 数组数据排序的程序例子
·2012-5-21 15:43:23 纯ASP上传图像文件到数据库的最佳例子
·2012-5-21 15:41:10 ASP程序中输出Excel文件实例一则
·2012-5-21 15:38:32 Jmail发信的实例,模块化随时调用
·2012-5-21 15:37:46 编写一个asp代码执行器
·2012-5-21 15:37:45 使用VB编写纯ASP程序
·2012-5-21 15:36:57 一个简单的网上书城的例子(六)
·2012-5-21 15:34:12 无组件上传图片至SQLSERVER数据库
·2012-5-21 15:33:19 ASP连接执行程序 
站长推荐 PS笔刷下载 在线翻译 系统进程 广告代码
  发表评论
姓 名: 验证码:
内 容:
教程搜索服务
ASP源码推荐
·Gxjss留言本 v1.1
·WAP2.0手机导航站源码 v1.0
·清竹网络营销员管理系统 v1.0
·29街网上城市简单公司网站 v1.0
·颓废者论坛 v1.0 简约版
·nblog 1.1 release
·ip转城市(asp+access) v1.0
·多域名查询系统 v1.3
·m006电影联盟 v10.07
·SIVA日志 v3.0
·良友在线校友录 v1.0
·易网团员信息管理系统(网络升级
项目外包信息
·汽车配件网站制作 50000元
·整站SEO优化
·课件门户网程序
·求长期合作网站设计制作高手
·公司网站重新改版 8000元
·asp企业网站小改动
·网站flash片头
·文化传播公司网站设计稿
·UI界面设计
·产品外观改版设计 15000元
·照明灯具网站设计 10000元
·求长期合作网站设计制作高手
·做B2C网站 20000元
·Android或QT软硬件平台设计(工
·网站首页FLASH
发布信息 浏览信息
邮件订阅服务
输入你的邮件地址,你将不会错过任何关于<ASP实例>的内容


网络编程文章分类
ASP教程
ASP实例
ASP技巧
ASP文摘
PHP教程
PHP技巧
PHP实例
PHP文摘
JSP教程
JSP技巧
JSP实例
JSP文摘
ASP.NET教程
ASP.NET技巧
ASP.NET实例
ASP.NET应用
xml教程
xsl教程
xml技巧
C#教程
C#应用
Delphi教程
Perl教程
Shell教程
Ajax教程
Visual Basic教程
Java教程
J2EE/J2ME教程
C/C++教程
移动解决方案
移动短信技术
移动行业动态
软件工程
WordPress
Android开发
站长工具:Google PR查询|Alexa排名查询|网站速度测试|CSS在线编辑器|OPEN参数生成器|弹出式窗口代码产生器|密码登录生成器|在线按钮生成器|Meta标签生成器|邮箱图标在线生成|多色彩特效字代码生成器|网页代码调试器|在线FTP登陆|Flash取色器|配色代码对照表|配色辞典|CSS生成器|CSS在线压缩|广告代码|框架网页代码生成器|js/vbs加密|md5加密|进制转换|UTF-8 转换工具|在线调色板|Html转换js|Html转换asp|Html转换php|Html转换perl
实用工具:汉字翻译拼音|拼音字典|在线翻译|天气预报|火星文|在线网速测试|符号对照表|个税计算|理财工具|黄金价格|购房银行按揭利率计算|汇率查询|经典小工具|汉字简繁转换|普通单位换算|公制单位换算|生辰老黄历|国内电话区号|国家代码与域名缩写|文字加密解密|元素周期表|健康查询|世界时间|全国各地车牌查询|全国车辆交通违章查询|万年历|二十四节气|汉字横竖排版|手机号码查询|计算器|ip搜索|酒店预订|机票预订
广告刊登 | 版权声明 | 联系我们 | 加入收藏 | RSS订阅
Copyright © 2000-2012 www.knowsky.com All rights reserved | 沪ICP备05001343号