ASP 正则表达式函数

Function Regex_Match(strOriginalString, strPattern, blnIgnoreCase)
	' Function matches pattern, returns true or false
	' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive)
	Dim objRegExp : Set objRegExp = New RegExp
	
	With objRegExp
		.Pattern = strPattern
		.IgnoreCase = blnIgnoreCase
		.Global = True
	End With
	
	ereg = objRegExp.test(strOriginalString)
	Set objRegExp = Nothing
End Function

Function Regex_Replace(strOriginalString, strPattern, strReplacement, blnIgnoreCase, blnGlobal)
	' Function replaces pattern with replacement
	' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive)
	Dim objRegExp : Set objRegExp = New RegExp
	
	With objRegExp
		.Pattern = strPattern
		.IgnoreCase = blnIgnoreCase
		.Global = blnGlobal
	End With
	
	ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
	Set objRegExp = Nothing
End Function

ASP 如何使用内容协商将XHTML作为XML提供给Internet Explorer 6和7

<%
If InStr(Request.ServerVariables("HTTP_ACCEPT"), "application/xhtml+xml") > 0 Then
    Response.ContentType = "application/xhtml+xml"
Else
    Response.ContentType = "application/xml"
End If
Response.Charset = "utf-8"
%>
<?xml-stylesheet type="text/xsl" href="xhtml.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML</title>
</head>

<body>

<!--
Contents of xhtml.xsl file

<stylesheet version="1.0"
     xmlns="http://www.w3.org/1999/XSL/Transform">
    <template match="/">
        <copy-of select="."/>
    </template>
</stylesheet>
-->


</body>
</html>

ASP 三角函数库

<%
    ' ASP Trigonometry Library
    '
    ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
    '
    ' This work is licensed under the Creative Commons Attribution License. To view
    ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
    ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
    ' 94305, USA.
    
    ' CIRCULAR FUNCTIONS

    ' There are six basic trigonometric functions, three of which (sine, cosine, and tangent) are already defined in ASP.
    ' function sin() - Returns the sine of the specified angle.
    ' function cos() - Returns the cosine of the specified angle.
    ' function tan() - Returns the tangent of the specified angle.
    
    ' The other three basic trigonometric functions are the multiplicative inverses of the previous three functions.

    ' Returns the cosecant of the specified angle.
    function csc(x)
        csc = 1 / sin(x)
    end function

    ' Returns the secant of the specified angle.
    function sec(x)
        sec = 1 / cos(x)
    end function

    ' Returns the cotangent of the specified angle.
    function cot(x)
        cot = 1 / tan(x)
    end function
    
    ' The following trigonometric functions are rarely used anymore, but are included in this function library for completeness.

    ' Returns the versed sine (also called versine) of the specified angle.
    function versin(x)
        versin = 1 - cos(x)
    end function

    ' Returns the coversed sine (also called coversine) of the specified angle.
    function coversin(x)
        coversin = 1 - sin(x)
    end function

    ' Returns the haversed sine (also called haversine) of the specified angle.
    function haversin(x)
        haversin = versin(x) / 2
    end function

    ' Returns the hacoversed sine (also called hacoversine, cohaversine, or havercosine) of the specified angle.
    function hacoversin(x)
        hacoversin = coversin(x) / 2
    end function
    
    ' Returns the exsecant of the specified angle.
    function exsec(x)
        exsec = sec(x) - 1
    end function

    ' Returns the excosecant of the specified angle.
    function excsc(x)
        excsc = csc(x) - 1
    end function

    ' Each of the six basic trigonometric functions also has an inverse function.

    ' Returns the angle whose sine is the specified number.
    function asin(x)
        asin = atn(x / sqr(-x * x + 1))
    end function

    ' Returns the angle whose cosine is the specified number.
    function acos(x)
        acos = atn(-x / sqr(-x * x + 1)) + 2 * atn(1)
    end function

    ' Returns the angle whose tangent is the specified number.
    ' This function is already defined in ASP, but has been aliased here for consistency with other programming languages.
    function atan(x)
        atan = atn(x)
    end function
    
    ' Returns the angle whose cosecant is the specified number.
    function acsc(x)
        acsc = atn(x / sqr(x * x - 1)) + (sin(x) - 1) * (2 * atn(1))
    end function

    ' Returns the angle whose secant is the specified number.
    function asec(x)
        asec = atn(x / sqr(x * x - 1)) + sin((x) - 1) * (2 * atn(1))
    end function

    ' Returns the angle whose cotangent is the specified number.
    function acot(x)
        acot = atn(x) + 2 * atn(1)
    end function


    ' HYPERBOLIC FUNCTIONS

    ' The hyperbolic functions are like the basic trigonometric functions, but for hyperbola instead of circles.

    ' Returns the hyperbolic sine of the specified angle.
    function sinh(x)
        sinh = (exp(x) - exp(-x)) / 2
    end function

    ' Returns the hyperbolic cosine of the specified angle.
    function cosh(x)
        cosh = (exp(x) + exp(-x)) / 2
    end function

    ' Returns the hyperbolic tangent of the specified angle.
    function tanh(x)
        tanh = (exp(x) - exp(-x)) / (exp(x) + exp(-x))
    end function

    ' Returns the hyperbolic cosecant of the specified angle.
    function csch(x)
        csch = 2 / (exp(x) - exp(-x))
    end function

    ' Returns the hyperbolic secant of the specified angle.
    function sech(x)
        sech = (2 / (exp(x) + exp(-x)))
    end function

    ' Returns the hyperbolic cotangent of the specified angle.
    function coth(x)
        coth = (exp(x) + exp(-x)) / (exp(x) - exp(-x))
    end function
    
    ' Just like in trigonometry, the six basic hyperbolic functions have inverse functions.

    ' Returns the angle whose hyperbolic sine is the specified number.
    function asinh(x)
        asinh = log(x + sqr(x * x + 1))
    end function
    
    ' Returns the angle whose hyperbolic cosine is the specified number.
    function acosh(x)
        acosh = log(x + sqr(x * x - 1))
    end function

    ' Returns the angle whose hyperbolic tangent is the specified number.
    function atanh(x)
        atanh = log((1 + x) / (1 - x)) / 2
    end function
    
    ' Returns the angle whose hyperbolic cosecant is the specified number.
    function acsch(x)
        acsch = log((sin(x) * sqr(x * x + 1) + 1) / x)
    end function

    ' Returns the angle whose hyperbolic secant is the specified number.
    function asech(x)
        asech = log((sqr(-x * x + 1) + 1) / x)
    end function

    ' Returns the angle whose hyperbolic cotangent is the specified number.
    function acoth(x)
        acoth = log((x + 1) / (x - 1)) / 2
    end function
    
    
    ' GUDERMANNIAN FUNCTIONS
    
    ' The Gudermannian function relates the circular and hyperbolic trigonometric functions without resorting to complex numbers.
    function gd(x)
        gd = 2 * atn(tanh(x / 2))
    end function
    
    ' Like other trigonometric and hyperbolic functions, Gudermannian has an inverse.
    function agd(x)
        agd = atanh(sin(x))
    end function
%>

ASP 温度转换

<%
    ' ASP Temperature Conversion Library
    '
    ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
    '
    ' This work is licensed under the Creative Commons Attribution License. To view
    ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
    ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
    ' 94305, USA.
    '
    ' This function library allows conversion between temperatures in the following scales:
    ' Celsius, Delisle, Fahrenheit, Kelvin, Newton, Rankine, Reaumur, and Romer.
    '
    ' Refer to Wikipedia for information on these temperature scales.
    
    ' Facade function, in case you'd rather not call the individual functions directly or you just like encapsulation.
    function convertTemperature(temperature, originScale, targetScale)
        ' Return the input value for temperature if both scales are identical.
        if UCASE(originScale) = UCase(targetScale) then
            convertTemperature = temperature
            exit function
        end if

        Select Case UCase(originScale)
        Case "CELSIUS"
            Select Case UCase(targetScale)
            Case "DELISLE"
                convertTemperature = CelsiusToDelisle(temperature)
            Case "FAHRENHEIT"
                convertTemperature = CelsiusToFahrenheit(temperature)
            Case "KELVIN"
                convertTemperature = CelsiusToKelvin(temperature)
            Case "NEWTON"
                convertTemperature = CelsiusToNewton(temperature)
            Case "RANKINE"
                convertTemperature = CelsiusToRankine(temperature)
            Case "REAUMUR"
                convertTemperature = CelsiusToReaumur(temperature)
            Case "ROMER"
                convertTemperature = CelsiusToRomer(temperature)
            End Select
        Case "DELISLE"
            Select Case UCase(targetScale)
            Case "CELSIUS"
                convertTemperature = DelisleToCelsius(temperature)
            Case "FAHRENHEIT"
                convertTemperature = DelisleToFahrenheit(temperature)
            Case "KELVIN"
                convertTemperature = DelisleToKelvin(temperature)
            Case "NEWTON"
                convertTemperature = DelisleToNewton(temperature)
            Case "RANKINE"
                convertTemperature = DelisleToRankine(temperature)
            Case "REAUMUR"
                convertTemperature = DelisleToReaumur(temperature)
            Case "ROMER"
                convertTemperature = DelisleToRomer(temperature)
            End Select
        Case "FAHRENHEIT"
            Select Case UCase(targetScale)
            Case "CELSIUS"
                convertTemperature = FahrenheitToCelsius(temperature)
            Case "DELISLE"
                convertTemperature = FahrenheitToDelisle(temperature)
            Case "KELVIN"
                convertTemperature = FahrenheitToKelvin(temperature)
            Case "NEWTON"
                convertTemperature = FahrenheitToNewton(temperature)
            Case "RANKINE"
                convertTemperature = FahrenheitToRankine(temperature)
            Case "REAUMUR"
                convertTemperature = FahrenheitToReaumur(temperature)
            Case "ROMER"
                convertTemperature = FahrenheitToRomer(temperature)
            End Select
        Case "KELVIN"
            Select Case UCase(targetScale)
            Case "CELSIUS"
                convertTemperature = KelvinToCelsius(temperature)
            Case "DELISLE"
                convertTemperature = KelvinToDelisle(temperature)
            Case "FAHRENHEIT"
                convertTemperature = KelvinToFahrenheit(temperature)
            Case "NEWTON"
                convertTemperature = KelvinToNewton(temperature)
            Case "RANKINE"
                convertTemperature = KelvinToRankine(temperature)
            Case "REAUMUR"
                convertTemperature = KelvinToReaumur(temperature)
            Case "ROMER"
                convertTemperature = KelvinToRomer(temperature)
            End Select
        Case "NEWTON"
            Select Case UCase(targetScale)
            Case "CELSIUS"
                convertTemperature = NewtonToCelsius(temperature)
            Case "DELISLE"
                convertTemperature = NewtonToDelisle(temperature)
            Case "FAHRENHEIT"
                convertTemperature = NewtonToFahrenheit(temperature)
            Case "KELVIN"
                convertTemperature = NewtonToKelvin(temperature)
            Case "RANKINE"
                convertTemperature = NewtonToRankine(temperature)
            Case "REAUMUR"
                convertTemperature = NewtonToReaumur(temperature)
            Case "ROMER"
                convertTemperature = NewtonToRomer(temperature)
            End Select
        Case "RANKINE"
            Select Case UCase(targetScale)
            Case "CELSIUS"
                convertTemperature = RankineToCelsius(temperature)
            Case "DELISLE"
                convertTemperature = RankineToDelisle(temperature)
            Case "FAHRENHEIT"
                convertTemperature = RankineToFahrenheit(temperature)
            Case "KELVIN"
                convertTemperature = RankineToKelvin(temperature)
            Case "NEWTON"
                convertTemperature = RankineToNewton(temperature)
            Case "REAUMUR"
                convertTemperature = RankineToReaumur(temperature)
            Case "ROMER"
                convertTemperature = RankineToRomer(temperature)
            End Select
        Case "REAUMUR"
            Select Case UCase(targetScale)
            Case "CELSIUS"
                convertTemperature = ReaumurToCelsius(temperature)
            Case "DELISLE"
                convertTemperature = ReaumurToDelisle(temperature)
            Case "FAHRENHEIT"
                convertTemperature = ReaumurToFahrenheit(temperature)
            Case "KELVIN"
                convertTemperature = ReaumurToKelvin(temperature)
            Case "NEWTON"
                convertTemperature = ReaumurToNewton(temperature)
            Case "RANKINE"
                convertTemperature = ReaumurToRankine(temperature)
            Case "ROMER"
                convertTemperature = ReaumurToRomer(temperature)
            End Select
        Case "ROMER"
            Select Case UCase(targetScale)
            Case "CELSIUS"
                convertTemperature = RomerToCelsius(temperature)
            Case "DELISLE"
                convertTemperature = RomerToDelisle(temperature)
            Case "FAHRENHEIT"
                convertTemperature = RomerToFahrenheit(temperature)
            Case "KELVIN"
                convertTemperature = RomerToKelvin(temperature)
            Case "NEWTON"
                convertTemperature = RomerToNewton(temperature)
            Case "RANKINE"
                convertTemperature = RomerToRankine(temperature)
            Case "REAUMUR"
                convertTemperature = RomerToReaumur(temperature)
            End Select
        End Select
    end function

    ' Converts a given temperature from Celsius to Delisle.
    function CelsiusToDelisle(temperature)
        CelsiusToDelisle = (100 - temperature) * 3 / 2
    end function

    ' Converts a given temperature from Celsius to Fahrenheit.
    function CelsiusToFahrenheit(temperature)
        CelsiusToFahrenheit = (temperature * 9 / 5) + 32
    end function
    
    ' Converts a given temperature from Celsius to Kelvin.
    function CelsiusToKelvin(temperature)
        CelsiusToKelvin = temperature + 273.15
    end function
    
    ' Converts a given temperature from Celsius to Newton.
    function CelsiusToNewton(temperature)
        CelsiusToNewton = temperature * 33 / 100
    end function
    
    ' Converts a given temperature from Celsius to Rankine.
    function CelsiusToRankine(temperature)
        CelsiusToRankine = (temperature + 273.15) * 1.8
    end function
    
    ' Converts a given temperature from Celsius to Reaumur.
    function CelsiusToReaumur(temperature)
        CelsiusToReamur = temperature * 4 / 5
    end function
    
    ' Converts a given temperature from Celsius to Romer.
    function CelsiusToRomer(temperature)
        CelsiusToRomer = temperature * 21 / 40 + 7.5
    end function
    
    ' Converts a given temperature from Delisle to Celsius.
    function DelisleToCelsius(temperature)
        DelisleToCelsius = 100 - temperature * 2 / 3
    end function
    
    ' Converts a given temperature from Delisle to Fahrenheit.
    function DelisleToFahrenheit(temperature)
        DelisleToFahrenheit = 212 - temperature * 6 / 5
    end function

    ' Converts a given temperature from Delisle to Kelvin.
    function DelisleToKelvin(temperature)
        DelisleToKelvin = 373.15 - temperature * 2 / 3
    end function
    
    ' Converts a given temperature from Delisle to Newton.
    function DelisleToNewton(temperature)
        DelisleToNewton = 33 - temperature * 11 / 50
    end function
    
    ' Converts a given temperature from Delisle to Rankine.
    function DelisleToRankine(temperature)
        DelisleToRankine = 671.67 - temperature * 6 / 5
    end function
    
    ' Converts a given temperature from Delisle to Reaumur.
    function DelisleToReaumur(temperature)
        DelisleToReaumur = 80 - temperature * 8 / 15
    end function
    
    ' Converts a given temperature from Delisle to Romer.
    function DelisleToRomer(temperature)
        DelisleToRomer = 60 - temperature * 7 / 20
    end function

    ' Converts a given temperature from Fahrenheit to Celsius.
    function FahrenheitToCelsius(temperature)
        FahrenheitToCelsius = (temperature - 32) * 5 / 9
    end function
    
    ' Converts a given temperature from Fahrenheit to Delisle.
    function FahrenheitToDelisle(temperature)
        FahrenheitToDelisle = (212 - temperature) * 5 / 6
    end function
    
    ' Converts a given temperature from Fahrenheit to Kelvin.
    function FahrenheitToKelvin(temperature)
        FahrenheitToKelvin = (temperature - 32) * 5 / 9 + 273.15
    end function
    
    ' Converts a given temperature from Fahrenheit to Newton.
    function FahrenheitToNewton(temperature)
        FahrenheitToNewton = (temperature - 32) * 11 / 60
    end function
    
    ' Converts a given temperature from Fahrenheit to Rankine.
    function FahrenheitToRankine(temperature)
        FahrenheitToRankine = temperature + 459.67
    end function
    
    ' Converts a given temperature from Fahrenheit to Reamur.
    function FahrenheitToReaumur(temperature)
        FahrenheitToReaumur = (temperature - 32) * 4 / 9
    end function
    
    ' Converts a given temperature from Fahrenheit to Romer.
    function FahrenheitToRomer(temperature)
        FahrenheitToRomer = (temperature - 32) * 7 / 24 + 7.5
    end function

    ' Converts a given temperature from Kelvin to Celsius.
    function KelvinToCelsius(temperature)
        KelvinToCelsius = temperature - 273.15
    end function
    
    ' Converts a given temperature from Kelvin to Delisle.
    function KelvinToDelisle(temperature)
        KelvinToDelisle = (373.15 - temperature) * 3 / 2
    end function
    
    ' Converts a given temperature from Kelvin to Fahrenheit.
    function KelvinToFahrenheit(temperature)
        KelvinToFahrenheit = (temperature - 273.15) * 9 / 5 + 32
    end function
    
    ' Converts a given temperature from Kelvin to Newton.
    function KelvinToNewton(temperature)
        KelvinToNewton = (temperature - 273.15) * 33 / 100
    end function
    
    ' Converts a given temperature from Kelvin to Rankine.
    function KelvinToRankine(temperature)
        KelvinToRankine = temperature * 1.8
    end function
    
    ' Converts a given temperature from Kelvin to Reaumur.
    function KelvinToReaumur(temperature)
        KelvinToReaumur = (temperature - 273.15) * 4 / 5
    end function
    
    ' Converts a given temperature from Kelvin to Romer.
    function KelvinToRomer(temperature)
        KelvinToRomer = (temperature - 273.15) * 21 / 40 + 7.5
    end function
    
    ' Converts a given temperature from Newton to Celsius.
    function NewtonToCelsius(temperature)
        NewtonToCelsius = temperature * 100 / 33
    end function
    
    ' Converts a given temperature from Newton to Delisle.
    function NewtonToDelisle(temperature)
        NewtonToDelisle = (33 - temperature) * 50 / 11
    end function

    ' Converts a given temperature from Newton to Fahrenheit.
    function NewtonToFahrenheit(temperature)
        NewtonToFahrenheit = temperature * 60 / 11 + 32
    end function
    
    ' Converts a given temperature from Newton to Kelvin.
    function NewtonToKelvin(temperature)
        NewtonToKelvin = temperature * 100 / 33 + 273.15
    end function
    
    ' Converts a given temperature from Newton to Rankine.
    function NewtonToRankine(temperature)
        NewtonToRankine = temperature * 60 / 11 + 491.67
    end function
    
    ' Converts a given temperature from Newton to Reaumur.
    function NewtonToReaumur(temperature)
        NewtonToReaumur = temperature * 80 / 33
    end function
    
    ' Converts a given temperature from Newton to Romer.
    function NewtonToRomer(temperature)
        NewtonToRomer = temperature * 35 / 22 + 7.5
    end function

    ' Converts a given temperature from Rankine to Celsius.
    function RankineToCelsius(temperature)
        RankineToCelsius = (temperature / 1.8) - 273.15
    end function
    
    ' Converts a given temperature from Rankine to Delisle.
    function RankineToDelisle(temperature)
        RankineToDelisle = (671.67 - temperature) * 5 / 6
    end function

    ' Converts a given temperature from Rankine to Fahrenheit.
    function RankineToFahrenheit(temperature)
        RankineToFahrenheit = temperature - 459.67
    end function
    
    ' Converts a given temperature from Rankine to Kelvin.
    function RankineToKelvin(temperature)
        RankineToKelvin = temperature / 1.8
    end function
    
    ' Converts a given temperature from Rankine to Newton.
    function RankineToNewton(temperature)
        RankineToNewton = (temperature - 491.67) * 11 / 60
    end function

    ' Converts a given temperature from Rankine to Reaumur.
    function RankineToReaumur(temperature)
        RankineToReaumur = (temperature * 5 / 9 - 273.15) * 4 / 5
    end function
    
    ' Converts a given temperature from Rankine to Romer.
    function RankineToRomer(temperature)
        RankineToRomer = (temperature - 491.67) * 7 / 24 + 7.5
    end function
    
    ' Converts a given temperature from Reaumur to Celsius.
    function ReaumurToCelsius(temperature)
        ReaumurToCelsius = temperature * 5 / 4
    end function
    
    ' Converts a given temperature from Reaumur to Delisle.
    function ReaumurToDelisle(temperature)
        ReaumurToDelisle = (80 - temperature) * 15 / 8
    end function
    
    ' Converts a given temperature from Reaumur to Fahrenheit.
    function ReaumurToFahrenheit(temperature)
        ReaumurToFahrenheit = temperature * 9 / 4 + 32
    end function

    ' Converts a given temperature from Reaumur to Kelvin.
    function ReaumurToKelvin(temperature)
        ReaumurToKelvin = temperature * 5 / 4 + 273.15
    end function

    ' Converts a given temperature from Reaumur to Newton.
    function ReaumurToNewton(temperature)
        ReaumurToNewton = temperature * 33 / 80
    end function

    ' Converts a given temperature from Reaumur to Rankine.
    function ReaumurToRankine(temperature)
        ReaumurToRankine = temperature * 9 / 4 + 491.67
    end function
    
    ' Converts a given temperature from Reaumur to Romer.
    function ReaumurToRomer(temperature)
        ReaumurToRomer = temperature * 21 / 32 + 7.5
    end function
    
    ' Converts a given temperature from Romer to Celsius.
    function RomerToCelsius(temperature)
        RomerToCelsius = (temperature - 7.5) * 40 / 21
    end function
    
    ' Converts a given temperature from Romer to Delisle.
    function RomerToDelisle(temperature)
        RomerToDelisle = (60 - temperature) * 20 / 7
    end function
    
    ' Converts a given temperature from Romer to Fahrenheit.
    function RomerToFahrenheit(temperature)
        RomerToFahrenheit = (temperature - 7.5) * 24 / 7 + 32
    end function

    ' Converts a given temperature from Romer to Kelvin.
    function RomerToKelvin(temperature)
        RomerToKelvin = (temperature - 7.5) * 40 / 21 + 273.15
    end function
    
    ' Converts a given temperature from Romer to Newton.
    function RomerToNewton(temperature)
        RomerToNewton = (temperature - 7.5) * 22 / 35
    end function
    
    ' Converts a given temperature from Romer to Rankine.
    function RomerToRankine(temperature)
        RomerToRankine = (temperature - 7.5) * 24 / 7 + 491.67
    end function
    
    ' Converts a given temperature from Romer to Reaumur.
    function RomerToReaumur(temperature)
        RomerToReaumur = (temperature - 7.5) * 32 / 21
    end function
%>

ASP 将0添加到一位数字

function a0(n)
	n = trim(n)
	a0 = n

	if trim(n) = "" then exit function

	n = cstr(n)

	if len(n) < 2 then n = "0" & n
	a0 = n
end function

ASP 用ASP检查复数 - 一个简单的检验复数函数

function CheckPlural(input)
	if input << 1 then
		CheckPlural = "s"
	else
		CheckPlural = ""
	end if
end function


'function can be called like so:
'25 Vote<%=CheckPlural(25)%>

ASP 罗马数字

<%
    ' ASP Roman Numeral Library
    '
    ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
    '
    ' This work is licensed under the Creative Commons Attribution License. To view
    ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
    ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
    ' 94305, USA.

    ' Convert Arabic numerals into Roman numerals.
    function roman(ByVal arabic)
        Dim fractions
        Dim ones
        Dim tens
        Dim hundreds
        Dim thousands

        fractions = Array("", "�¢ï¿½�¢", "�¢ï¿½�¢�¢ï¿½�¢", "�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢", "�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢", "�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢", "S", "S�¢ï¿½�¢", "S�¢ï¿½�¢�¢ï¿½�¢", "S�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢", "S�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢", "S�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢�¢ï¿½�¢", "I")
        ones = Array("", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX")
        tens = Array("", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC")
        hundreds = Array("", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM")
        thousands = Array("", "M", "MM", "MMM", "MMMM")
    
        if arabic > 4999 then
            ' For large numbers (five thousand and above), a bar is placed above a base numeral to indicate multiplication by 1000.
            ' Since it is not possible to illustrate this in plain ASCII, this function will refuse to convert numbers above 4999.
            Err.Clear
            Err.Raise 9
        elseif arabic = 0 then
            ' About 725, Bede or one of his colleagues used the letter N, the initial of nullae,
            ' in a table of epacts, all written in Roman numerals, to indicate zero.
            roman = "N"
        else
            ' Handle fractions that will round up to 1.
            if round((arabic mod 1) * 12) = 12 then
                arabic = round(arabic)
            end if

            ' With special cases out of the way, we can proceed.
            roman = thousands((arabic - (arabic mod 1000)) / 1000)
            arabic = arabic mod 1000
            roman = roman & hundreds((arabic - (arabic mod 100)) / 100)
            arabic = arabic mod 100
            roman = roman & tens((arabic - (arabic mod 10)) / 10)
            arabic = arabic mod 10
            roman = roman & ones((arabic - (arabic mod 1)) / 1)
            arabic = arabic mod 1

            ' Handling for fractions.
            if arabic > 0 then
                roman = roman & fractions(round(arabic * 12))
            end if
        end if
    end function
    
    ' Expand subtractive notation in Roman numerals.
    function roman_expand(ByVal roman)
        roman = replace(roman, "CM", "DCCCC")
        roman = replace(roman, "CD", "CCCC")
        roman = replace(roman, "XC", "LXXXX")
        roman = replace(roman, "XL", "XXXX")
        roman = replace(roman, "IX", "VIIII")
        roman = replace(roman, "IV", "IIII")
        roman_expand = roman
    end function

    ' Compress Roman numerals using subtractive notation.
    function roman_compress(ByVal roman)
        roman = replace(roman, "DCCCC", "CM")
        roman = replace(roman, "CCCC", "CD")
        roman = replace(roman, "LXXXX", "XC")
        roman = replace(roman, "XXXX", "XL")
        roman = replace(roman, "VIIII", "IX")
        roman = replace(roman, "IIII", "IV")
        roman_compress = roman
    end function
    
    ' Convert Roman numerals to Arabic numerals.
    ' Requires InstrCount()
    function arabic(ByVal roman)
        Dim result
        
        result = 0
        
        ' Remove subtractive notation.
        roman = roman_expand(roman)
        
        ' Calculte for each numeral.
        result = result + InstrCount(roman, "M") * 1000
        result = result + InstrCount(roman, "D") * 500
        result = result + InstrCount(roman, "C") * 100
        result = result + InstrCount(roman, "L") * 50
        result = result + InstrCount(roman, "X") * 10
        result = result + InstrCount(roman, "V") * 5
        result = result + InstrCount(roman, "I")
    end function

    ' Validate a roman number.
    function isRoman(roman)
        dim regEx
        set regEx = new RegExp

        with regEx
            .IgnoreCase = true
            .Global = true
            .Pattern = "[MDCLXVI]"
        end with

        if regEx.Test(roman) then
            isRoman = true
        else
            isRoman = false
        end if

        set regEx = nothing
    end function
%>

ASP 阶乘

<%
    ' ASP Mathematics Library - Factorial
    '
    ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
    '
    ' This work is licensed under the Creative Commons Attribution License. To view
    ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
    ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
    ' 94305, USA.
    
    ' Determine the factorial for a given number
    function factorial(x)
        dim result
        
        result = 1

        if x > 1 then
            for i = 2 to x
                result = result * i
            next
        end if
        
        factorial = result
    end function
    
    ' Returns the number of combinations, without regard to order, of y items that can be made from a pool of x items.
    ' Requires factorial()
    function combinatorial(x, y)
        if (x >= y) and (y > 0) then
            combinatorial = factorial(x) / factorial(y) / factorial(x - y)
        else
            combinatorial = 0
        end if
    end function

    ' Returns the number of permutations, with regard to order, of y items that can be made from a pool of x items.
    ' Requires factorial()
    function permutations(x, y)
        permutations = factorial(x) / factorial(x - y)
    end function
%>

ASP 上午下午

<%
    ' Copyright (c) 2008, www.thecanonman.com; some rights reserved.
    '
    ' This work is licensed under the Creative Commons Attribution License. To view
    ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
    ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
    ' 94305, USA.
    
    ' Returns either AM or PM, given a Time value.
    function ampm(someTime)
        if hour(someTime) < 12 then
            ampm = "AM"
        else
            ampm = "PM"
        end if
    end function 
%>

ASP 是字母

<%
    ' Copyright (c) 2008, www.thecanonman.com; some rights reserved.
    '
    ' This work is licensed under the Creative Commons Attribution License. To view
    ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
    ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
    ' 94305, USA.
    
    ' Checks if a string contains only alpha characters.
    function isAlpha(someString)
        dim regEx

        set regEx = new RegExp
        
        with regEx
            .Global = true
            .IgnoreCase = true
            .Pattern = "[A-Z\s_]"
        end with
        
        if regEx.test(someString) then
            isAlpha = true
        else
            isAlpha = false
        end if
    
        set regEx = nothing
    end function
%>