1、为数字,如果字符串为空,则返回0值CreateObject()函数建立和返回一个已注册的ACTIVEX组件的实例。表达式 CreateObject(objName) objName 是任何一个有效、已注册的ACTIVEX组件的名字.Set con = Server.CreateObject(ADODB.ConnectionCStr()函数转化一个表达式为字符串.表达式 CStr(expression) expression 是任何有效的表达式。s = 3 + 2response.write The 返回结果 is: & cStr(s) 转化数字“5”为字符“5”。Date()函数返回当前系统日
2、期.表达式 Date() None.%=Date% 9/9/00DateAdd()函数返回一个被改变了的日期。表达式 DateAdd(timeinterval,number,date)timeinterval is the time interval to add;number is amount of time intervals to add;and date is the starting date.currentDate = #9/9/00#newDate = DateAdd(m,3,currentDate)response.write newDate 4FormatCurrency(
3、)函数返回表达式,此表达式已被格式化为货币值表达式 FormatCurrency(Expression , Digit , LeadingDigit , Paren , GroupDigit) Digit 指示小数点右侧显示位数的数值。默认值为 -1,指示使用的是计算机的区域设置; LeadingDigit 三态常数,指示是否显示小数值小数点前面的零。%=FormatCurrency(34.3456)% 34.35FormatDateTime()函数返回表达式,此表达式已被格式化为日期或时间表达式 FormatDateTime(Date, , NamedFormat) NamedFormat
4、指示所使用的日期/时间格式的数值,如果省略,则使用 vbGeneralDate.%=FormatDateTime(09/9/00, vbLongDate)% Sunday, September 09, 2000FormatNumber()函数返回表达式,此表达式已被格式化为数值.表达式 FormatNumber(Expression , Digit , LeadingDigit , Paren , GroupDigit)默认值为 -1,指示使用的是计算机的区域设置。 LeadingDigit i指示小数点右侧显示位数的数值。 Paren 指示小数点右侧显示位数的数值。 GroupDigit i
5、指示小数点右侧显示位数的数值。.%=FormatNumber(45.324567, 3)% 45.325FormatPercent()函数返回表达式,此表达式已被格式化为尾随有 % 符号的百分比(乘以 100 )。 (%)表达式 FormatPercent(Expression , Digit , LeadingDigit , Paren , GroupDigit) 同上.%=FormatPercent(0.45267, 3)% 45.267%Hour()函数以24时返回小时数.表达式 Hour(time)%=Hour(#4:45:34 PM#)% 16(Hour has been conve
6、rted to 24-hour system)Instr()函数返回字符或字符串在另一个字符串中第一次出现的位置.表达式 Instr(start, strToBeSearched, strSearchFor , compare) Start为搜索的起始值,strToBeSearched接受搜索的字符串 strSearchFor要搜索的字符.compare比较方式(详细见ASP常数)strText = This is a test!pos = Instr(strText, aresponse.write pos 9InstrRev()函数同上,只是从字符串的最后一个搜索起表达式 InstrRev
7、(start, strToBeSearched, strSearchFor , compare)pos = InstrRev(strText, 13Int()函数返回数值类型,不四舍五入。表达式 Int(number)%=INT(32.89)% 32IsArray()函数判断一对象是否为数组,返回布尔值 .表达式 IsArray(name)strTest = Test!response.write IsArray(strTest) FalseIsDate()函数判断一对象是否为日期,返回布尔值表达式 IsDate(expression)9/4/2000response.write IsDate
8、(strTest) TrueIsEmpty()函数判断一对象是否初始化,返回布尔值.表达式 IsEmpty(expression)Dim iresponse.write IsEmpty(i)IsNull()函数判断一对象是否为空,返回布尔值.表达式 IsNull(expression)response.write IsNull(i)IsNumeric()函数判断一对象是否为数字,返回布尔值.表达式 IsNumeric(expression)i = 345response.write IsNumeric(i) True就算数字加了引号,ASP还是认为它是数字。IsObject()函数判断一对象是
9、否为对象,返回布尔值.表达式 IsObject(expression)response.write IsObject(con)LBound()函数返回指定数组维的最小可用下标.表达式 Lbound(arrayname , dimension)i = Array(TuesdayWednesdayresponse.write LBound(i) 0LCase()函数 返回字符串的小写形式表达式 Lcase(string)response.write LCase(strTest) this is a test!Left()函数返回字符串左边第length个字符以前的字符(含第length个字符).表
10、达式 Left(string, length)response.write Left(strTest, 3) ThiLen()函数返回字符串的长度.表达式 Len(string | varName)response.write Len(strTest) 15LTrim()函数去掉字符串左边的空格.表达式 LTrim(string) This is a test!response.write LTrim(strTest)Mid()函数返回特定长度的字符串(从start开始,长度为length).表达式 Mid(string, start , length) Today is Monday.res
11、ponse.write Mid(strTest, 17, 5) TodayMinute()函数返回时间的分钟.表达式 Minute(time)%=Minute(#12:32 PM#)% 45Month()函数返回日期.表达式 Month(date)%=Month(#08/04/99#)% 8MonthName()函数返回指定月份表达式 MonthName(month, , Abb)%=MonthName(Month(#08/04/99#)% AugustNow()函数返回系统时间表达式 Now()%=Now% 9/9/00 9:30:16 AMRight()函数返回字符串右边第length个字
12、符以前的字符(含第length个字符).表达式 Right(string, length)%This is an test!response.write Right(strTest, 3) st!Rnd()函数产生一个随机数.表达式 Rnd (number) Randomize()Randomize()response.write RND() 任何一个在0 到 1 之间的数Round()函数返回按指定位数进行四舍五入的数值.表达式 Round(expression , numRight)i = 32.45678response.write Round(i)Rtrim()函数去掉字符串右边的字符
13、串.表达式 Rtrim(string)response.write RTrim(strTest)Split()函数将一个字符串分割并返回分割结果表达式 Split (S,d)%V= Split(A,B,C)For i = 0 To UBound(V)Response.Write V(i) A B CSecond()函数返回秒.表达式 Second(time)%=Second(#12:28 PM#)% 28StrReverse()函数反排一字符串表达式 StrReverse(string)response.write StrReverse(strTest) !tset a si sihTTime
14、()函数返回系统时间.表达式 Time()%=Time% 9:58:28 AMTrim()函数去掉字符串左右的空格.表达式 Trim(string)response.write Trim(strTest)UBound()函数返回指定数组维数的最大可用下标表达式 Ubound(arrayname , dimension)response.write UBound(i) 2UCase()函数返回字符串的大写形式.表达式 UCase(string)response.write UCase(strTest) THIS IS A TEST!VarType()函数返回指示变量子类型的值表达式 VarTyp
15、e(varName)i = 3response.write varType(i) 2(数字)详见asp常数WeekDay()函数返回在一周的第几天.表达式 WeekDay(date , firstdayofweek)d = #9/9/00#response.write Weekday(d) 4(星期三)WeekDayName()函数返回一周第几天的名字.表达式 WeekDayName(weekday , Abb , firstdayofweek)response.write WeekdayName(Weekday(d) WednesdayYear()函数返回当前的年份.表达式 Year(dat
16、e)%=Year(#9/9/00#)%续:今日是:%=year(now)%年月日 显示: 2003年10月31日 星期五VBScript有许多函数,使你可以得到各种格式的日期和时间。你已经用过了这些函数中的一个。你可以用函数NOW返回当前的日期和时间:At the tone,the time will bi:%=NOW%你应该注意,返回的日期和时间是你的Web服务器的系统时钟的日期和时间。如果身处纽约的某个人在看你的网页,他看到的日期和时间与她当地的日期和时间也许是不一至的。函数NOW同时返回日期和时间。如果你只想返回当前日期,你可以使用函数DATE。如果你只想返回当前时间,你可以使用函数TIME。例如:The date is :%=DATE%The time is :%=TIME%操作日期使用函数MONTH(),DAY(),WEEKDAY(),和YEAR(),你可以把一个日期分割成更小的部分。所有这些函数都以一个日期
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1