Recommended: ASP tip example: Several lines of code solve the problem of preventing repeated submissions of forms In many cases, it is necessary to prevent the same form from being submitted multiple times. Many people's implementation methods are relatively complicated (the number of code exceeds dozens of lines!!) The following provides a method that only requires a few lines of code, which easily prevents users from refreshing multiple submissions and using the back button to re-examine the form.
1. Function array()
Function: Create an array variable
Format: array(list)
Parameter: list is each numeric column in the array variable, with comma intervals in the middle
example:
<% i = array (1,2,3) %>
Result: i is assigned as an array
2. Function Cint()
Function: Convert an expression/other type of variable into an integer type (int)
Format: Cint(expression)
Parameter:expression is any valid expression/other type variable
example:
<%
f = 234
response.write cINT(f) 2
%>
Results: 236
The function Cint() converts the character 234 into an integer 234. If the expression is empty or invalid, the return value is 0;
3. Function: Creatobject()
Function: Create and return an ActiveX object.
Format: Creatobject(obname)
The parameter bname is the name of the object
example:
<%
Set con = Server.CreateObject(ADODB.Connection)
%>
result:
4. Function Cstr()
Function: Convert an expression/other type of variable into a character type (string)
Format: Cstr(expression)
Parameters: expression is any valid expression/other type variable
example:
<%
s = 3 2
response.write The result is: & cStr(s)
%>
Result: The function Cstr() converts integer 5 into character 5.
5. Function Date()
Function: Return the date of the current system (server side)
Format: Date()
Parameters: None
Example <% date () %>
Results: 06/13/07
6. Function Dateadd()
Function: Calculate a specified time and
Format: dateadd(timeinterval,number,date)
Parameters: timeinterval is the time unit (month, day...); number is the time interval value, and date is the time starting point.
example:
<%
currentDate = #6/13/07#
newDate = DateAdd(m,3,currentDate)
response.write newDate
%> <%
currentDate = #12:34:45 PM#
newDate = DateAdd(h,3,currentDate)
response.write newDate
%>
result:
13/6/07
3:34:45 PM
in
m = month;
d = day;
If it is the currentDate format, then,
h = hour;
s = second;
7. Function Datediff()
Function: Calculate a specified time difference of a certain quantity
Format: datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]])
Parameters: timeinterval is the time unit; date1 and date2 are valid date expressions, firstdayofweek, firstdayofyear are any options.
example:
<%
fromDate = #8/4/99#
toDate = #1/1/2000#
response.write There are & _
DateDiff(d,fromDate,toDate) & _
days to millionium from 8/4/99.
%>
Results: There are 150 days to millionium from 8/4/99.
8. Function day()
Function: Return an integer value corresponding to a day of a certain month
Format: day(date)
Parameters: date is a valid date expression;
Example <% =date(#8/4/99#) %>
Results: 4
9. Function formatcurrency()
Function: Convert to currency format
Format: formatcurrency(expression [,digit[,leadingdigit[,paren[,groupdigit]]]])
Parameters: expression is a valid numeric expression; digit represents the number of digits after the decimal point; leadingdigit, paren, groupdigit are any options.
Example <%=FormatCurrency(34.3456)%>
Results 34.35
10. Function Formatdatetime()
Function: Format date expression/variable
Format: formatdatetime(date[,nameformat])
Parameters: date is a valid date expression/variable; nameformat is the specified date format constant name.
Example <% =formatdatetime(08/04/99,vblongdate) %>
Results: Wednesday, August 04,1999
illustrate:
--------------------------------------------------------------------------------
describe
Returns the expression, which has been formatted as a date or time.
grammar
FormatDateTime(Date[, NamedFormat])
The syntax of the FormatDateTime function has the following parameters:
Parameter description
Date Required. The date expression to be formatted.
NamedFormat Optional. Values indicating the date/time format used, if omitted, use vbGeneralDate.
set up
The NamedFormat parameter can have the following values:
Constant value description
vbGeneralDate 0 Displays the date and/or time. If there is a date section, the section is displayed in a short date format. If there is a time part, the part is displayed in a long time format. If all exist, all sections are displayed.
vbLongDate 1 Display dates using the long date format specified in the computer locale.
vbShortDate 2 Displays dates using the short date format specified in the computer locale.
vbLongTime 3 Display time using the time format specified in the computer locale.
vbShortTime 4 Displays time in 24-hour format (hh:mm).
illustrate
The following example uses the FormatDateTime function to format the expression as a long date type and assign it to MyDateTime:
Function GetCurrentDate
FormatDateTime Format the date type to a long date type.
GetCurrentDate = FormatDateTime(Date, 1)
End Function
--------------------------------------------------------------------------------
<script language=vbs>
for i=0 to 4
alert( formatdatetime(now,&i&) is: &formatdatetime(now,i))
next
</script>
11. Function Isnumeric()
Function: Return a Boolean value to determine whether the variable is a numeric variable, or other variables that can be converted into numbers.
Format: isnumeric(expression)
Parameter:expression is an arbitrary variable.
example:
<%
i=234
response.write isnumeric(i)
%>
Result: true.
12. Function Isobject()
Function: Return a Boolean value to determine whether the variable is an object variable,
Format: isobject(expression)
Parameters: expression is an arbitrary variable.
example:
<%
set con =server.creatobject(adodb.connection)
response.write isobject(con)
%>
Result: true
13. Function: Lbound()
Function: Return the lower bound of an array.
Format: Lbound(arrayname[, dimension])
Parameter: arrayname is an array variable, dimension is any item
example:
<%
i = array(1,2,3)
response.write lbound(i)
%>
Results: 0
14. Function Lcase()
Function: Transform all characters of a character type variable into lowercase characters.
Format: Lcase(string)
Parameter: string is a string variable
example:
<%
str=THIS is Lcase!
response.write Lcase(str)
%>
Result: this is lcase!
15. Function left()
Function: Intercept the first part of a string;
Format: left(string, length)
Parameters: string string, length intercepted by length.
Example: <% =left(this is a test!,6) %>
Results: this i
16. Function len()
Function: Return the string length or the byte length of the variable
Format:len(string *varname)
Parameter: string; varname any variable name
example:
<%
strtest=this is a test!
response.write len(strtest)
%>
Results: 15
17. Function ltrim()
Function: Remove the spaces before the string.
Format: ltrim(string)
Parameters: string string.
Example: <% =ltrim ( this is a test!)
Results: this is a test!
18. Function Mid()
Function: Snap strings from strings.
Format: mid(string,start [,length])
Parameters: string string, the starting point of start intercept, and the length to intercept.
example:
<%
strtest=this is a test, Today is Monday!
response.write mid(strtest,17,5)
%>
Results: Today
19. Function minute()
Function: Return a value, representing minutes
Format: minute(time)
Parameters: time is a time variable
Example lt;% = minute(#12:23:34#) %>
Results: 23
20. Function month()
Function: Return a value, representing the month
Format: month(time)
Parameter: time is a date variable
Example <% =month(#08/09/99) %>
Results: 9
21. Function monthname()
Function: Returns the string (name) of the month.
Format: Monthname(date [,abb])
Parameters: date is a date variable, when abb=true, the abbreviation of the month,
example:
<% =monthname(#4/5/99#) %>
Results: April
22. Function Now()
Function: Returns the current time and date of the system.
Format: now()
Parameters: None
example:
<% =now() %>
Results: 05/10/00 8:45:32 pm
23. Function: replace()
Function: Look up in a string, instead of the specified string.
Format: replace(strtobesearched,strsearchfor,strreplacewith [,start[,count[,compare]]])
Parameters: strtobesearched is a string; strsearchfor is the substring being looked up; strreplacewith is the substring used to replace. start, count, compare are any options.
example:
<%
strtest=this is an apple.
response.write replace(strtest,apple,orange)
%>
Results: this is an orange.
24. Function right()
Function: Intercept the latter part of a string
Format: right(string, length)
Parameters: string string, length intercepted by length.
example:
<%
strtest=this is a test!
response.write right(strtest,3)
%>
Results: st!
25. Function rnd()
Function: Return a random number
Format: rnd[(number)]
Parameter: number is any numeric value.
example:
<%
randomize()
response.write rnd()
%>
Result: If one of the 0/1 values is one of the values, without randomize(), no random number can be generated.
26. Function round()
Function: Full value
Format: round(expression[,numright])
Parameters: expression numeric expression; numright arbitrary options.
example:
<%
i=12.33654
response.write round(i)
%>
Results: 12
27. Function rtrim()
Function: Remove spaces after strings.
Format: rtrim(string)
Parameter: string is a string
example:
<%
response.write rtrim(this is a test! )
%>
Results: this is a test!
28. Function second()
Function: Return an integer value.
Format: second(time)
Parameter: time is a valid time expression;
Example lt;% =second(# 12:28:30#) %>
Results: 30
29. Function strReverse()
Function: Returns a string inversely arranged with the original string.
Format:strreverse(string)
Parameter: string is a string
Example <% =strreverse(this is a test!)
Result:!tset a si siht
30. Function time()
Function: Returns the time value of the current system.
Format: time()
Parameters: None
Results: 9:58:28 Am
31. Function trim()
Function: Delete the spaces before and after the string.
Format:trim(string)
Parameters: string string.
example:
<%
strtest= this is a test!
response.write trim(strtest)
%>
Results: this is a test!
32. Function UBound()
Function: Return the upper bound of an array.
Format: Ubound(expression [, dimension])
Parameters: expression is an array expression/array variable, dimension is any item
example:
<%
i = array(1,2,3)
response.write ubund(i)
%>
Results: 2
33. Function: UCase()
Function: Convert all characters of a character type variable into capital characters.
Format: Ucase(string)
Parameter: string is a string variable
example:
<%
str=THIS is Lcase!
response.write Lcase(str)
%>
Results: THIS IS LCASE!
34. Function Vartype()
Function: Return the constant code of the variable (integral)
Format: Vartype(varname)
Parameter: varname is a variable name of any type.
example:
<%
i=5
response.write vartype(i)
%>
Result: 2 (2 represents an integer, you need to refer to the ASP constant code.)
35. Function Weekday()
Function: Return an integer corresponding to the day of the week.
Format: Weekday(date [,firstofweek])
Parameters: date is a date variable, firstofweek is any option.
example:
<%
d= # 5/9/00 #
response.write weekday(d) %>
Results: 3 (3 means Tuesday)
36. Function weekdayname()
Function: Returns the string, corresponding to the day of the week.
Format: weekdayname(weekday[,abb[,firstdayofweek]])
Parameters: weekday is the date variable, abb, firstdayofweek is any option.
example:
<%
d = #8/4/99#
response.write weekdayname(d)
%>
Results: Wednesday
37. Function year()
Function: Returns the year where the date expression is located.
Format: year(date)
Parameters: date is a valid date expression
example:
<% =year(#8/9/99#) %>
Results: 1999
38. Function Mod() function: take the remainder.
Example: 3 Mod 2
Results: 1
Share: ASP Development Guidelines The application server is, or will eventually be used by a web server, and it is usually the IIS computer running the ASP page. ASP is the only client of your object. It brings special threading and security considerations. Although many Web sites that use ASP do not use it at all