新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > wincc中使用vbs常用函數

        wincc中使用vbs常用函數

        作者: 時間:2011-06-23 來源:網絡 收藏
        6.Dateadd()

        本文引用地址:http://www.104case.com/article/150569.htm

          功能:計算某個指定的時間和

          格式: 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_r [,digit[,leadingdigit[,paren[,groupdigit]]]])

          參數: expression_r 是有效的數字表達式;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

          說明:

          --------------------------------------------------------------------------------

          描述

          返回表達式,此表達式已被格式化為日期或時間。

          語法

          FormatDateTime(Date[, NamedFormat])

          FormatDateTime 函數的語法有以下參數:

          參數 描述

          Date 必選項。要被格式化的日期表達式。

          NamedFormat 可選項。指示所的日期/時間格式的數值,如果省略,則 vbGeneralDate。

          設置

          NamedFormat 參數可以有以下值:

          常數 值 描述

          vbGeneralDate 0 顯示日期和/或時間。如果有日期部分,則將該部分顯示為短日期格式。如果有時間部分,則將該部分顯示為長時間格式。如果都存在,則顯示所有部分。

          vbLongDate 1 計算機區域設置中指定的長日期格式顯示日期。

          vbShortDate 2 使用計算機區域設置中指定的短日期格式顯示日期。

          vbLongTime 3 使用計算機區域設置中指定的時間格式顯示時間。

          vbShortTime 4 使用 24 小時格式 (hh:mm) 顯示時間。

          說明

          下面例子利用 FormatDateTime 函數把表達式格式化為長日期型并且把它賦給 MyDateTime:

          Function GetCurrentDate

          “FormatDateTime 把日期型格式化為長日期型。

          GetCurrentDate = FormatDateTime(Date, 1)

          End Function

          11.函數Isnumeric()

          功能:返回一個布爾值,判斷變量是否為數字變量,或者是可以轉換成數字的其它變量.

          格式:isnumeric(expression_r)

          參數:expression_r 是任意的變量.

          例子:

          %

          i=“234”

          response.write isnumeric(i)

          %>

          結果: true.

          12.函數Isobject()

          功能:返回一個布爾值,判斷變量是否為對象的變量,

          格式: isobject(expression_r)

          參數: expression_r 是任意的變量.

          例子:

          %

          set con =server.creatobject(“adodb.connection”)

          response.write isobject(con)

          %>

          結果: true

          13.函數:Lbound()

          功能:返回一個數組的下界.

          格式:Lbound(arrayname[,dimension])

          參數:arrayname 是數組變量,dimension 是任意項

          例子:

          %

          i = array(“1”,”2”,”3”)

          response.write lbound(i)

          %>

          結果:0

          14.函數Lcase()

          功能:將一字符類型變量的字符全部變換小寫字符.

          格式:Lcase(string)

          參數:string是字符串變量

          例子:

          %

          str=“THIS is Lcase!”

          response.write Lcase(str)

          %>

          結果:this is lcase!



        關鍵詞: 函數 常用 vbs 使用 wincc

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 富源县| 合江县| 车险| 布拖县| 汶上县| 平凉市| 吐鲁番市| 大安市| 彰武县| 呼伦贝尔市| 金川县| 会理县| 上饶市| 通河县| 永清县| 秦安县| 英山县| 金山区| 拉孜县| 仪征市| 沾益县| 和林格尔县| 湛江市| 河曲县| 广饶县| 永胜县| 南京市| 福州市| 奉节县| 西昌市| 镇雄县| 鄯善县| 海淀区| 台中市| 右玉县| 天水市| 蒙自县| 岳池县| 寿宁县| 宜都市| 吉安县|