⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdlib.asp

📁 WAPmo手机网站管理平台是一款创建与管理维护WAP网站的的软件产品
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<%
'--------------------------------------------------------------------
' stdlib.asp - standard library
'
' Copyright (c) 2006 - 2008 MOEx Group.
'
'
' last update: 2008/06/16
'
'--------------------------------------------------------------------

'--------------------------------------------------------------------
' IIf               - 根据表达式的值,来返回两部分中的其中一个
'                   - 返回类型:Variant
'                   - arguments[0] = 表达式(type: Boolean Or Integer Or Long)
'                   - arguments[1] = 表达式为真,返回该参数(type: Variant)
'                   - arguments[2] = 表达式为假,返回该参数(type: Variant)
'--------------------------------------------------------------------
Public Function IIf(ByVal blnExp, vtTrue, vtFalse)
    If CBool(blnExp) Then
        IIf = vtTrue
    Else
        IIf = vtFalse
    End If
End Function

'--------------------------------------------------------------------
' ChangeType        - 转换未知类型的数据为指定类型的数据
'                   - 返回类型:Any
'                   - arguments[0] = 未知类型的数据(type: Variant)
'                   - arguments[1] = 指定类型,VarType常数(type: Long)
'--------------------------------------------------------------------
Public Function ChangeType(vtData, ByVal vtType)
    Dim ret
    Select Case vtType
    Case vbEmpty
    Case vbNull
        ret = Null
    Case vbInteger
        ret = ChangeType(vtData, vbDouble)
        If ret >= -32768 And ret <= 32767 Then
            ret = CInt(ret)
        Else
            ret = 0
        End If
    Case vbLong
        ret = ChangeType(vtData, vbDouble)
        If ret >= -2147483648 And ret <= 2147483647 Then
            ret = CLng(ret)
        Else
            ret = CLng(0)
        End If
    Case vbSingle
        If IsNumeric(vtData) Then
            ret = CSng(vtData)
        ElseIf VarType(vtData) = vbDecimal Then
            ret = CSng(vtData)
        Else
            ret = CSng(0)
        End If
    Case vbDouble
        If IsNumeric(vtData) Then
            ret = CDbl(vtData)
        ElseIf VarType(vtData) = vbDecimal Then
            ret = CDbl(vtData)
        Else
            ret = CDbl(0)
        End If
    Case vbCurrency
        ret = ChangeType(vtData, vbDouble)
        If ret >= -922337203685477.5808 And ret <= 922337203685477.5807 Then
            ret = CCur(ret)
        Else
            ret = CCur(0)
        End If
    Case vbDate
        If IsDate(vtData) Then
            ret = CDate(vtData)
        End If
    Case vbString
        If Not IsNull(vtData) Then
            ret = CStr(vtData)
        Else
            ret = Empty
        End If
    Case vbBoolean
        ret = ChangeType(vtData, vbDouble)
        ret = CBool(Not ret = 0)
    Case vbByte
        ret = ChangeType(vtData, vbLong)
        ret = CByte(ret And &HFF)
    Case Else
        ret = vtData
    End Select
    ChangeType = ret
End Function

'--------------------------------------------------------------------
' atos              - 未知类型的数据转String类型的数据
'                   - 返回类型:String
'                   - arguments[0] = 未知类型的数据(type: Variant)
'--------------------------------------------------------------------
Public Function atos(vtData)
    atos = ChangeType(vtData, vbString)
End Function

'--------------------------------------------------------------------
' atoi              - 未知类型的数据转Integer类型的数据
'                   - 返回类型:Integer
'                   - arguments[0] = 未知类型的数据(type: Variant)
'--------------------------------------------------------------------
Public Function atoi(vtData)
    atoi = ChangeType(vtData, vbInteger)
End Function

'--------------------------------------------------------------------
' atol              - 未知类型的数据转Long类型的数据
'                   - 返回类型:Long
'                   - arguments[0] = 未知类型的数据(type: Variant)
'--------------------------------------------------------------------
Public Function atol(vtData)
    atol = ChangeType(vtData, vbLong)
End Function

'--------------------------------------------------------------------
' atof              - 未知类型的数据转Double类型的数据
'                   - 返回类型:Double
'                   - arguments[0] = 未知类型的数据(type: Variant)
'--------------------------------------------------------------------
Public Function atof(vtData)
    atof = ChangeType(vtData, vbDouble)
End Function

'--------------------------------------------------------------------
' isdigit           - 判断指定字节是否是数字字节
'                   - 返回类型:Boolean
'                   - arguments[0] = 指定字节(type: Integer)
'--------------------------------------------------------------------
Public Function isdigit(ByVal iValue)
    isdigit = CBool(iValue >= 48 And iValue <= 57)
End Function

'--------------------------------------------------------------------
' isalpha           - 判断指定字节是否是字母字节
'                   - 返回类型:Boolean
'                   - arguments[0] = 指定字节(type: Integer)
'--------------------------------------------------------------------
Public Function isalpha(ByVal iValue)
    isalpha = CBool((iValue >= 65 And iValue <= 90) Or (iValue >= 97 And iValue <= 122))
End Function

Public Function isupper(ByVal iValue)
    isupper = CBool(iValue >= 65 And iValue <= 90)
End Function

Public Function islower(ByVal iValue)
    islower = CBool(iValue >= 97 And iValue <= 122)
End Function

'--------------------------------------------------------------------
' isalnum           - 判断指定字节是否是数字或字母字节
'                   - 返回类型:Boolean
'                   - arguments[0] = 指定字节(type: Integer)
'--------------------------------------------------------------------
Public Function isalnum(ByVal iValue)
    isalnum = CBool(isdigit(iValue) Or isalpha(iValue))
End Function

'--------------------------------------------------------------------
' isxdigit          - 判断指定字节是否是十六进制字节
'                   - 返回类型:Boolean
'                   - arguments[0] = 指定字节(type: Integer)
'--------------------------------------------------------------------
Public Function isxdigit(ByVal iValue)
    isxdigit = CBool((iValue >= 48 And iValue <= 57) Or (iValue >= 65 And iValue <= 70) Or (iValue >= 97 And iValue <= 102))
End Function

'--------------------------------------------------------------------
' isascii           - 判断指定字节是否是ASCII字节
'                   - 返回类型:Boolean
'                   - arguments[0] = 指定字节(type: Integer)
'--------------------------------------------------------------------
Public Function isascii(ByVal iValue)
    isascii = CBool(iValue > 0 And iValue < 128)
End Function

Public Function isspace(ByVal iValue)
    isspace = CBool((iValue >= 9 And iValue <= 13) Or iValue = 32)
End Function

'--------------------------------------------------------------------
' LShift            - 将指定整数左移指定位数,不超过32位
'                   - 返回类型:Long
'                   - arguments[0] = 指定整数(type: Long)
'                   - arguments[1] = 指定位数(type: Integer)
'--------------------------------------------------------------------
Public Function LShift(ByVal lValue, ByVal iBit)
    LShift = lValue * (2 ^ iBit)
End Function

'--------------------------------------------------------------------
' RShift            - 将指定整数右移指定位数,不超过32位
'                   - 返回类型:Long
'                   - arguments[0] = 指定整数(type: Long)
'                   - arguments[1] = 指定位数(type: Integer)
'--------------------------------------------------------------------
Public Function RShift(ByVal lValue, ByVal iBit)
    RShift = lValue \ (2 ^ iBit)
End Function

'--------------------------------------------------------------------
' MAKEWORD          - 将高位字节和低位字节转换为整数
'                   - 返回类型:Long
'                   - arguments[0] = 高字节(type: Integer)
'                   - arguments[1] = 低字节(type: Integer)
'--------------------------------------------------------------------
Public Function MAKEWORD(ByVal iHigh, ByVal iLow)
    MAKEWORD = (iHigh And &HFF) Or LShift((iLow And &HFF), 8)
End Function

'--------------------------------------------------------------------
' MAKELONG          - 将高位整数和低位整数转换为长整数
'                   - 返回类型:Long
'                   - arguments[0] = 高位整数(type: Long)
'                   - arguments[1] = 低位整数(type: Long)
'--------------------------------------------------------------------
Public Function MAKELONG(ByVal iHigh, ByVal iLow)
    MAKELONG = (iHigh And &HFFFF&) Or LShift((iLow And &HFFFF&), 16)
End Function

'--------------------------------------------------------------------
' LOWORD            - 返回指定长整数的低位整数
'                   - 返回类型:Long
'                   - arguments[0] = 指定长整数(type: Long)
'--------------------------------------------------------------------
Public Function LOWORD(ByVal lValue)
    LOWORD = lValue And &HFFFF&
End Function

'--------------------------------------------------------------------
' HIWORD            - 返回指定长整数的高位整数
'                   - 返回类型:Long
'                   - arguments[0] = 指定长整数(type: Long)
'--------------------------------------------------------------------
Public Function HIWORD(ByVal lValue)
    HIWORD = RShift(lValue, 16) And &HFFFF&
End Function

'--------------------------------------------------------------------
' LOBYTE            - 返回指定整数的低位字节
'                   - 返回类型:Byte
'                   - arguments[0] = 指定长整数(type: Long)
'--------------------------------------------------------------------
Public Function LOBYTE(ByVal iValue)
    LOBYTE = CByte(iValue And &HFF)
End Function

'--------------------------------------------------------------------
' HIBYTE            - 返回指定整数的高位字节
'                   - 返回类型:Byte
'                   - arguments[0] = 指定长整数(type: Long)
'--------------------------------------------------------------------
Public Function HIBYTE(ByVal iValue)
    HIBYTE = CByte(RShift(iValue, 8) And &HFF)
End Function

'--------------------------------------------------------------------
' ntol              - 将网络字节顺序的字节串转为整数
'                   - 返回类型:Long
'                   - arguments[0] = 指定长整数(type: Long)
'--------------------------------------------------------------------
Public Function ntol(ByVal vtData)
    Dim ret, i
    ret = 0
    For i = LenB(vtData) To 1 Step -1
        ret = MAKEWORD(AscB(MidB(vtData, i, 1)), ret)
    Next
    ntol = ret
End Function

'--------------------------------------------------------------------
' htol              - 将主机字节顺序的字节串转为整数
'                   - 返回类型:Long
'                   - arguments[0] = 指定长整数(type: Long)
'--------------------------------------------------------------------
Public Function htol(ByVal vtData)
    Dim ret, i
    ret = 0
    For i = 1 To LenB(vtData)
        ret = MAKEWORD(AscB(MidB(vtData, i, 1)), ret)
    Next
    htol = ret
End Function

'--------------------------------------------------------------------
' InArray           - 判断指定数据是否在一个数组中
'                   - 返回类型:Boolean
'                   - arguments[0] = 数组(type: Array)
'                   - arguments[1] = 指定数据(type: Variant)
'                   - arguments[2] = 是否区分大小写(type: Boolean)
'--------------------------------------------------------------------
Public Function InArray(arr, ByVal strKey, ByVal blnCase)
    InArray = InString(Join(arr, "|"), strKey, blnCase)
End Function

'--------------------------------------------------------------------
' InString          - 判断指定数据是否在一个[***|***|***|...]格式的字符串中
'                   - 返回类型:Boolean
'                   - arguments[0] = 字符串(type: Variant)
'                   - arguments[1] = 指定数据(type: Variant)
'                   - arguments[2] = 是否区分大小写(type: Boolean)
'--------------------------------------------------------------------
Public Function InString(ByVal strData, ByVal strKey, ByVal blnCase)
    Dim str1, str2
    str1 = Replace("|$1|", "$1", strData)
    str2 = Replace("|$1|", "$1", strKey)
    If blnCase Then
        InString = CBool(InStr(str1, str2) > 0)
    Else
        InString = CBool(InStr(LCase(str1), LCase(str2)) > 0)
    End If
End Function

Public Function ArrayIndex(arr, ByVal vtValue)
    Dim i
    ArrayIndex = -1
    For i = 0 To UBound(arr)
        If arr(i) = vtValue Then
            ArrayIndex = i
        End If
    Next
End Function

'--------------------------------------------------------------------
' IsNumericArray    - 判断一个数组是否是数字数组
'                   - 返回类型:Boolean
'                   - arguments[0] = 数组(type: Array)
'--------------------------------------------------------------------
Public Function IsNumericArray(arr)
    Dim ptr

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -