<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      asp函數介紹

      [摘要]1.函數array()功能:創建一個數組變量格式:array(list)參數:list 為數組變量中的每個數值列,中間用逗號間隔例子:<% i = array ("1",&...

      1.函數array()
      功能:創建一個數組變量
      格式:array(list)
      參數:list 為數組變量中的每個數值列,中間用逗號間隔
      例子:
      <% i = array ("1","2",3) %>
      結果: i 被賦予為數組


      2.函數Cint()
      功能:將一表達式/其它類型的變量轉換成整數類型(int)
      格式:Cint(expression)
      參數:expression 是任何有效的表達式/其它類型的變量
      例子:
      <%
      f = "234"
      response.write cINT(f) + 2
      %> 
      結果: 236
      函數Cint()將字符"234"轉換 成整數234.如果表達式為空, 或者無效時,返回值為0;


      3.函數:Creatobject()
      功能:創建及返回一個ActiveX對象.
      格式:Creatobject(obname)
      參數:obname 是對象的名稱
      例子:
      <%
      Set con = Server.CreateObject("ADODB.Connection")
      %> 
      結果:


      4.函數Cstr()
      功能:將一表達式/其它類型的變量轉換成字符類型(string)
      格式:Cstr(expression)
      參數:expression是任何有效的表達式/其它類型的變量
      例子:
      <%
      s = 3 + 2
      response.write "The result is: " & cStr(s)
      %> 
      結果:函數Cstr()將整數 5 轉換 成字符"5".


      5.函數Date()
      功能:返回當前系統(server端)的日期
      格式:Date()
      參數:無
      例子:<% date () %>
      結果:05/10/00


      6.函數Dateadd()
      功能:計算某個指定的時間和
      格式:dateadd(timeinterval,number,date)
      參數:timeinterval是時間單位(月,日..); number是時間間隔值,date是時間始點.
      例子:
      <%
      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
      %> 
      結果:
      11/4/99
      3:34:45 PM
      其中
      "m" = "month";
      "d" = "day";
      如果是currentDate 格式,則,
      "h" = "hour"; 
      "s" = "second"; 


      7.函數Datediff()
      功能:計算某量個指定的時間差
      格式:datediff(timeinterval,date1,date2,firstdayofweek,firstdayofyear)
      參數:timeinterval 是時間單位; date1,date2是有效的日期表達式,firstdayofweek,firstdayofyear 是任意選項.
      例子:
      <%
      fromDate = 
      8/4/99

      toDate = 
      1/1/2000

      response.write "There are " & _
      DateDiff("d",fromDate,toDate) & _
      " days to millenium from 8/4/99."
      %> 
      結果:There are 150 days to millenium from 8/4/99. 


      8.函數day()
      功能:返回一個整數值,對應于某月的某日
      格式:day(date)
      參數:date是一個有效的日期表達式;
      例子:<% =date(
      8/4/99
      ) %>
      結果:4


      9.函數formatcurrency()
      功能:轉換成貨幣格式
      格式:formatcurrency(expression ,digit,leadingdigit,paren,groupdigit)
      參數:expression 是有效的數字表達式;digit表示小數點后的位數;leadingdigit,paren,groupdigit是任意選項.
      例子:<%=FormatCurrency(34.3456)%> 
      結果:$34.35


      10.函數Formatdatetime()
      功能:格式化日期表達式/變量
      格式:formatdatetime(date,nameformat)
      參數:date為有效的日期表達式/變量;nameformat是指定的日期格式常量名稱.
      例子:<% =formatdatetime("08/04/99",vblongdate) %>
      結果:Wednesday,August 04,1999


      11.函數formatnumber()
      功能:格式化數字表達式/變量
      格式:formatnumbe(expression ,digit,leadingdigit,paren,groupdigit)
      參數:express為有效的數字表達式, digit表示小數點后的位數;leadingdigit,paren,groupdigit是任意選項
      例子:
      <% =formatnumber(23.2225568 ,3 %> 
      結果: 23.222


      12.函數formatpercent()
      功能:格式化百分數表達式/變量
      格式:formatnumber(expression ,digit ,leading ,paren,groupdigit)
      參數:expression 是有效的數字表達式,digit表示小數點后的位數;leadingdigit,paren,groupdigit是任意選項
      例子:
      <% =formatpercent(0.4523366,3)%> 
      結果: 45.233


      13.函數:hour()
      功能:返回一個數值,對應于的指定時間.
      格式:hour(time)
      參數:time對應于的指定時間.
      例子:
      <% =hour(
      4:45:34 pm 
      ) %> 
      結果:16 (24 小時制)


      14.函數instr()
      功能:返回一個數值,對應于某字符(串)在另一字符串中的位置.
      格式:instr(start,strtobesearched,strsearchfor ,compare)
      參數:start(任選)是從第start位尋找,strtobesearched 是被搜索的字符串,strsearchfor是被尋找的目標.compare是任意選項
      例子:
      <%
      strtext="this is a test!!"
      pos=instr(strtext,"a")
      %> 
      結果:9,(字符"a"在strtext字符串的第九位)


      15.函數instrrev()
      功能:返回一個數值,對應于某字符(串)在另一字符串中的位置(從后面起開始尋找).
      格式:instrrev(start, strtobesearched,strsearchfor,compare)
      參數:參考 instr(),
      例子:
      <% 
      strtext="this is a test!!"
      pos=instrrev(strtext,"s")
      response.write pos
      %>
      結果:13, 字串"s"是strtext的第13個字符(從后面起開始尋找)


      16.函數int()
      功能:數字取整
      格式:int(number)
      參數:number 是任何有效的數字表達式/其它類型的變量
      例子:
      <% =int(322.96) %>
      結果:322 (如果用Cint()則結果是323)


      17.函數isarray()
      功能:返回一個布爾值,判斷變量是否為數組.
      格式: isarray(name)
      參數:name是變量名稱
      例子:
      <%
      str="text"
      response.write isdate(str)
      %> 
      結果:false


      18.函數isdate()
      功能:返回一個布爾值,判斷變量是否為日期變量.
      格式:isdate(expression)
      參數:expression 是任意的變量.
      例子:<%
      str="8/4/00"
      response.write isdate(str) 
      %>
      結果:true


      19.函數isempty()
      功能:返回一個布爾值,判斷變量是否為空.
      格式:isempty(expression)
      參數:expression 是任意的變量.
      例子:
      <%
      dim i
      response.write isempty(i)
      %>
      結果:true


      20.函數isnull()
      功能:返回一個布爾值,判斷變量是否包含非法的數據.
      格式:isnull(expression)
      參數:expression 是任意的變量.
      例子:
      <%
      dim i
      response.write isnull(i)
      %> 
      結果:false

      21.函數Isnumeric()
      功能:返回一個布爾值,判斷變量是否為數字變量,或者是可以轉換成數字的其它變量.
      格式:isnumeric(expression)
      參數:expression 是任意的變量.
      例子:
      <%
      i="234"
      response.write isnumeric(i)
      %> 
      結果: true.


      22.函數Isobject()
      功能:返回一個布爾值,判斷變量是否為對象的變量,
      格式:isobject(expression)
      參數:expression 是任意的變量.
      例子:
      <%
      set con =server.creatobject("adodb.connection")
      response.write isobject(con)
      %> 
      結果: true


      23.函數:Lbound()
      功能:返回一個數組的下界.
      格式:Lbound(arrayname,dimension)
      參數:arrayname 是數組變量,dimension 是任意項
      例子:
      <%
      i = array("1","2","3")
      response.write lbound(i)
      %> 
      結果:0


      24.函數Lcase()
      功能:將一字符類型變量的字符全部變換小寫字符.
      格式:Lcase(string)
      參數:string是字串變量
      例子:
      <%
      str="THIS is Lcase!"
      response.write Lcase(str)
      %> 
      結果:this is lcase!


      25.函數left()
      功能:截取一個字符串的前部分;
      格式:left(string,length)
      參數:string字符串,length截取的長度.
      例子: <% =left("this is a test!",6) %>
      結果:this i


      26.函數len()
      功能:返回字符串長度或者變量的字節長度
      格式:len(string  varname)
      參數:string字符串;varname任意的變量名稱
      例子:
      <%
      strtest="this is a test!"
      response.write left(strtest)
      %>
      結果:15


      27.函數ltrim()
      功能:去掉字符串前的空格.
      格式:ltrim(string)
      參數:string 字串.
      例子: <% =ltrim (" this is a test!")
      結果:this is a test!


      28.函數Mid()
      功能:從字串中截取字串.
      格式:mid(string,start ,length)
      參數:string字串,start截取的起點,length要截取的長度.
      例子:
      <%
      strtest="this is a test, Today is Monday!"
      response.write mid(strtest,17,5)
      %>
      結果:Today


      29.函數minute()
      功能:返回一數值, 表示分鐘
      格式:minute(time)
      參數: time是時間變量
      例子:<% =minute(
      12:23:34
      ) %>
      結果:23


      30.函數month()
      功能:返回一數值, 表示月份
      格式:month(time)
      參數:time是日期變量
      例子:<% =month(
      08/09/99) %>
      結果:9


      31.函數monthname()
      功能:返回月份的字符串(名稱).
      格式:Monthname(date ,abb)
      參數:date是日期變量,abb=true時 則月份的縮寫,
      例子:
      <% =monthname(
      4/5/99
      ) %> 
      結果:April


      32.函數Now()
      功能:返回系統的當前時間和日期.
      格式:now()
      參數:無
      例子:
      <% =now() %> 
      結果: 05/10/00 8:45:32 pm


      33.函數:replace()
      功能:在字串中查找,替代指定的字串.
      格式:replace(strtobesearched,strsearchfor,strreplacewith 

      ,start,count,compare)
      參數:strtobesearched是字串; strsearchfor是被查找的子字串;strreplacewith 

      是用來替代的子字串.start,count,compare 是任意選項.
      例子:
      <%
      strtest="this is an apple."
      response.write replace(strtest,"apple","orange")
      %> 
      結果:this is an orange.


      34.函數right()
      功能:截取一個字符串的后部分
      格式:right(string,length)
      參數:string字符串,length截取的長度.
      例子:
      <%
      strtest="this is a test!"
      response.write right(strtest,3)
      %> 
      結果:st!


      35.函數rnd()
      功能:返回一個隨機數值
      格式:rnd(number)
      參數:number是任意數值.
      例子:
      <%
      randomize()
      response.write rnd()
      %>
      結果:0/1數值之一,無randomize(), 則不能產生隨機數.


      36.函數round()
      功能:完整數值
      格式:round(expression,numright)
      參數:expression數字表達式;numright任意選項.
      例子:
      <%
      i=12.33654
      response.write round(i)
      %>
      結果: 12


      37.函數rtrim()
      功能:去掉字符串后的空格.
      格式:rtrim(string)
      參數:string 是字串
      例子:
      <%
      response.write rtrim("this is a test! ")
      %> 
      結果:this is a test!


      38.函數second()
      功能:返回一個整數值.
      格式:second(time)
      參數:time是一個有效的時間表達式;
      例子:<% =second(
      12:28:30
      ) %>
      結果:30


      39.函數strReverse()
      功能:返回與原字串排列逆向的字串.
      格式:strreverse(string)
      參數:string是字串
      例子:<% =strreverse("this is a test!")
      結果:!tset a si siht


      40.函數time()
      功能:返回當前系統的時間值.
      格式:time()
      參數:無
      結果:9:58:28 Am

      41.函數trim()
      功能:刪去字符串前,后的空格.
      格式:trim(string)
      參數:string 字串.
      例子:
      <%
      strtest=" this is a test! "
      response.write trim(strtest)
      %> 
      結果:this is a test!


      42.函數UBound()
      功能:返回一個數組的上界.
      格式:Ubound(expression ,dimension)
      參數:expression 是數組表達式/數組變量,dimension 是任意項
      例子:
      <%
      i = array("1","2","3")
      response.write ubound(i)
      %> 
      結果: 2


      43.函數:UCase()
      功能:將一字符類型變量的字符全部變換成大寫字符.
      格式:Ucase(string)
      參數:string是字串變量
      例子:
      <%
      str="THIS is Lcase!"
      response.write Lcase(str)

      %> 
      結果:THIS IS LCASE!


      44.函數Vartype()
      功能:返回變量的常量代碼(整數)
      格式:Vartype(varname)
      參數:varname是任何類型的變量名稱.
      例子:
      <%
      i=5
      response.write vartype(i)
      %> 
      結果:2 (2表示整數,須要參考ASP常量代碼.)


      45.函數Weekday()
      功能:返回一個整數,對應一周中的第幾天.
      格式:Weekday(date ,firstofweek)
      參數:date為日期變量,firstofweek為任選項.
      例子:
      <%
      d= 
      5/9/00 

      response.write weekday(d) %>
      結果:3(3 表示是星期二)


      46.函數weekdayname()
      功能:返回字串,對應星期幾.
      格式:weekdayname(weekday,abb,firstdayofweek)
      參數:weekday為日期變量,abb,firstdayofweek為任選項.
      例子:
      <%
      d = 
      8/4/99

      response.write weekdayname(d)
      %>
      結果: Wednesday


      47.函數year()
      功能:返回日期表達式所在的年份.
      格式:year(date)
      參數:date是有效的日期表達式
      例子:
      <% =year(
      8/9/99
      ) %> 
      結果:1999



      標簽:asp函數介紹 
      日韩精品一区二区三区高清