Recommended _FSO topics for VBScript commonly used functions in ASP

Source: Internet
Author: User
Tags abs chr comparison month name natural logarithm numeric value square root time interval
/*-------------------ASP Document reference set-----------------------* *
*--> Author: paramecium
*--> time: 2007-4.28---2007-4.30 (originally a manual written by oneself, now sent here)
*--> Contact: caolvchong@gmail.com
*--> Document Features:
1. Review the ASP, deepen the understanding of ASP structure and the experience of ASP
2. Can be used as an ASP reference, write their own, reference to more convenient

This is part five: the common functions of VBScript in ASP
/*-----------------------The common functions of VBScript in ASP---------------------* *
*--> Judgment class function:
IsArray (): Determines whether an array
Isdate (): Determines whether it is a time type of data. The data for the type of time can be as follows:
"October 19, 1962" or #2006/11/3# or #2006-11-3#
IsEmpty (): Determine if a variable is initialized, that is, whether the value is empty
Isnull (): Determine if the variable has nothing
IsNumeric (): Judge whether it is a number
IsObject (): To determine whether an object
The return value is a Boolean (True or FALSE)

*--> Common Conversion class functions:
Abs (): Absolute value function
ASC (): Returns the ANSI character code corresponding to the first letter of the string
The ASCB function is used in conjunction with a string containing byte data. ASCB is not a word that returns the first character Fudai
Code, but returns the first byte. The ASCW is provided for 32-bit platforms that use Unicode characters. it returns
Unicode (wide) character code, so you can avoid code conversions from ANSI to Unicode.
CHR (): Returns the character corresponding to the specified ANSI character code
The CHRB function is used in conjunction with the byte data contained in the string. CHRB not return one or two bytes
character, and always returns a single byte of character. ChrW is a 32-bit platform for using Unicode characters
Provided by. Its argument is a Unicode (wide-character) character code, so you can avoid turning ANSI
to Unicode characters.
Int (), Cint (), Fix () and CLng (): Returns an integer
Difference: Int () can accept long integer data, and always remove the data after the decimal point
Cint () can only accept short integer data, and processing decimal uses rounding
CLNG () accepts long integer data and also handles decimals with rounding
In a positive case, fix () and int () are the same, and the difference is negative:
The INT function returns the first negative integer less than or equal to number
The Fix function returns the first negative integer that is greater than or equal to the number argument
CSTR (): Returns a string

*--> commonly used time functions:
Date: Returns the current date of the system, output format such as: 2007-3-25
Time: Return to the current system, output format such as: 14:31:32
Year: Return years of time
Day: Returns the days ordinal of a date (that is, a number from 1 to 31)
Month: Returns the month ordinal of a date (that is, a number from 1 to 12)
Weekday: Returns the days of the week (numbers from 1 to 7)
Format: Weekday (date [, First day of the week]), by default Sunday is the first day
Weekday (date,2) is the first day in Monday, with 7 for the first day of Saturday
Hour: Returns the time of the hour (that is, 0 to 23)
Minute: Returns the minute of time (i.e. 0 to 59)
Second: The number of seconds to return (that is, 0 to 59)
Now: Returns the current specific time of the system, output format such as: 2007-5-2 14:32:49
MonthName (parameter 1[, parameter 2]): The month name of the corresponding date, 1 returns January ...
Numbers or expressions of arguments 1:1 through 12
Optional parameter 2:true or FALSE, return the month abbreviation in English
WeekdayName: Return to "Day of the Week"
Format: WeekdayName (days from the first day, whether abbreviated output, the first days specified)
By default, the first day means Sunday, 1, 2 is the first day of Monday, and so on
The first day of the day means, for example, the designation of the first 2, then the first of Monday,
And then the first day of the second days filled with 2, which means Tuesday, and so forth
Short: TRUE or false, return the week abbreviation in English
Here are a few functions about the time set value:
DATEADD (type, interval, base time): Returns the date that the specified time interval has been added
Type (to be enclosed in quotes):
YYYY: Year; Q: quarter; M: month; Y: day of year; d: Day; W: day of week; WW: week; h: hour;
N: minutes; s: sec
Interval: is a number, the number of intervals to set the value
Cardinality time: is a date function
Example:
Newdate = DateAdd ("M", 1, "31-jan-95")
Response. Write (Newdate)
Will output 1995-2-28
DateDiff (type, date 1, date 2[, which day is the first day of the week [, which Day is the first star of the year
Period]): Returns the time interval between two dates
Type: DateAdd of the same type as above
Date 1, date 2: two date time
The first day of the optional week is specified: defaults to Sunday as the first day
The first week of the year of choice specify: Default to the week of January 1
DatePart (type, date [, which day is the first day of the week [, which day is the first week of the Year]]):
Returns the specified portion of a given date
Type: DateAdd of the same type as above
Date: A number of dates or expressions
The first day of the optional week is specified: defaults to Sunday as the first day
The first week of the year of choice specify: Default to the week of January 1
Example: Use the newdate above
Reponse.write ("yyyy", newdate), will return 1995
DateSerial (Year,month,day): Returns the date format data for the specified month and day
For example:
DateSerial (1970,1,1) return to 1970-1-1
In addition: Year valid range 100-9999
DateValue (date String): Returns the corresponding date format data
TimeSerial (time, minutes, seconds): Returns date format data for a specified time
For example:
TimeSerial (15,2,6) return to 15:2:6
TimeValue (Time String): Returns the corresponding time format data

*--> Common Mathematical functions:
Trigonometric function:
Cos (): Returns cosine
Sin (): Returns a sine value
Tan (): Returns the tangent value
ATN (): Returns the inverse tangent value
Random function:
Randomize: Random seed Set Value
Rnd: Returns a random value less than 1 but greater than or equal to 0
Logarithmic functions:
Log (): Returns the natural logarithm of a numeric value of about 2.718282 for the constant E
EXP (): Returns the power exponent of E (base of natural logarithm), log inverse operation
Root function:
SQR (): Returns the square root of a value
Rounding Function:
Abs: Absolute Value function
Int,fix,cint can be rounded, as described above.
Round (): Rounding function
Format: Round (number or its expression [, digits])
Description of digits: Numbers indicate how many digits to the right of the decimal point are rounded. If omitted, the
Round function returns an integer
Example:
num=3.14159
Response.Write Round (num,2) ' Return 3.14
Symbolic functions:
SGN (): Symbols for judging numbers
0: Back to 0
Positive number: return 1
Negative numbers: Back-1

String handler function:
The most common string-handling functions:
Len (): Returns the string length (LenB: Returns the number of characters within a string)
Left (String,length): Returns the specified number of characters from the left-hand side of the string (LEFTB)
Mid (string, starting position [, length]): Returns a specified number of characters from a string
Returns the control string if the starting position exceeds the string length
Does not specify that the length or length exceeds the last character of the string, returning from the start position to the last
Characters (MIDB)
Right (String,length): Returns a specified number of characters from the right-hand side of the string (RIGHTB)
Note: The above LEFTB,MIDB,RIGHTB represents the use of byte data contained in a string. length
Does not specify the number of strings returned, but the number of bytes)
Replace (string expression, substring searched, substring used for substitution [, comparison [, number
[, starting position]]]
Description of optional Parameters:
Comparison: The default is 0, which indicates a binary comparison
Number: Number of substring substitutions performed. If omitted, the default value is-1, which means that all
Possible replacements. When associated with start position, you must use the
Start position: Number of substring substitutions performed. If omitted, the default value is-1, which means
Make all possible substitutions. When associated with number, you must use the
Trim (String): Remove the spaces on either side of the string
Rtrim (String): Remove the space on the right
Ltrim (String): Remove the left space
Split (string expression [, delimiter [, number [, starting position]]): Returns a one-dimensional array based on 0,
containing the specified number of substrings
Description
Separator: Optional, character used to identify the bounds of a substring. If omitted, use a space for
As the separator character. If delimiter is a zero-length string, the return contains the entire
Group of cell Primes for strings
Number and start position no longer described
Join (string expression [, separator]): A series of strings are attached to a string and delimited
Delimited. If the delimiter is omitted, the space character is used. Generally, a string expression is just an array of
Name can
Lcase (): all strings replaced by lowercase
Ucase (): All strings replaced by uppercase
INSTR (): Returns the position of the first occurrence of a string in another string
Format: InStr ([Starting position,] a string expression that accepts a search, a string expression to search for
-type [, whether to make binary comparisons])
Description
Not found return 0, there are function instrb, and the above. b function Similar
The default is binary comparison.
Functions that are relative to this function but have a different structure: InStrRev (), less used, requires
You can check the manual.
StrComp (string1,string2[, 2): Returns an indication of the string ratio
Values that are more than results
Description
If the string1 is less than string2, return-1;
If string1 is greater than string2, return 1;
If string1 equals string2, return 0;
Returns null if one of the string1 or string2 is null
In addition, the default is to make a 2-binary comparison. Set to 1 for text comparisons
Secondary common string processing functions:
Chr (), ChrB (), ChrW () and ASC (), ASCB (), AscW () said earlier
Space (): Returns a string consisting of a specified number of spaces
For example: space (10), returns a string consisting of 10 spaces
String (length, String): Returns a repeating character with a specified length
String
Description
Length: Returns the length of the string
String: Specifies the character code for a character or string expression, where the string expression
The first character is used to compose the returned string. If the character parameter package
Contains null, NULL is returned.
For example:
Dim MyString
MyString = String (5, "*") "returns" * * * *.
MyString = String (5, 42) ' Returns ' * * * * *.
MyString = String ("ABC") ' returns to Aaaaaaaaaa '
Other than that:
If the specified string value is greater than 255, String uses the following formula to
Convert to valid character code:
String Mod 256
StrReverse (String): Returns a string that is the opposite of the specified string order
Note: If string is a 0-length string (""), it returns a 0-length string. If
string is null, an error occurs
For example: MyStr = StrReverse ("VBScript") ' MyStr contains ' TPIRCSBV '

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.