ASP script variables, functions, procedures, and condition statements
Source: Internet
Author: User
In the previous period, the author briefly introduced some basic knowledge about VBScript, one of ASP scripting languages. In this period, I will continue to explain how to compile VBScript, by presenting a series of examples of VBScript in ASP Programming, you can better understand VBScript.
After learning the basic concepts of variables, constants, and processes in the script language VBScript, we will continue to introduce the functions and syntax of VBScript.
Functions and procedures are named code blocks, but they differ greatly. When a process completes a program task, the function returns a value. We can understand that the process is like a complete sentence, and the function is like a word. For example, if you want to obtain the square root of a number, you only need to transmit it to the Sqr () function of VBScript. This function returns the square root of the number immediately. For example:
A = sqr (9)
Then A = 3. Mastering the functions of the scripting language will bring you great convenience in writing ASP Programs. For the exercises that the author arranged at the end of the above phase for everyone after class, if you do not have full understanding of the functions in the scripting language, it may take a lot of effort to solve such a small problem. Now let's review this exercise after class.
"The author is using ASP to create a WEB-based BBS system and hopes to add a special feature to it, that is, after logging on to the BBS, any user can view all newly released information in the last seven days."
If you are not familiar with VBScrip, you will not know that VBScrip itself provides a function DateSerial to get the difference or sum between dates. Its syntax is as follows:
DateSerial (year, month, day)
If you want to specify a date, for example, January 1, November 10, 1998, the value range of each parameter in the DateSerial function should be acceptable. The value of today should be between 1 and 31, the value of the month should be between 1 and 12. However, you can also use a numeric expression indicating the year, month, and number of days before or after a specific day to specify a relative date for each parameter. The following example uses a numeric expression instead of an absolute date. Here, the DateSerial function returns the date of the second day (10-1) before January 1, 1990, and two months (11-2. The procedure is as follows:
Datep = DateSerial (1998-20, 11-2, 10-1)
For the year parameter, if the value range is from 0 to 99, it is interpreted as 1900 to 1999. For the year parameter beyond this range, four digits are used to represent the year (for example, January 1, 1800 ). When the value of any parameter is out of an acceptable range, it is carried to the next large time unit as appropriate. For example, if 35 days are specified, the number of days is interpreted as a month plus the number of days. The number of days is determined by the year and month. However, if the value of the parameter exceeds the range of-32,768 to 32,767, or the date specified by the three parameters (either directly or through the expression) exceeds the acceptable date range, an error occurs.
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