First, we need to understand
CINT range:-32,768 to 32,767.
The range of clng is-2,147,483,648 to 2,147,483,647.
Meaning of CINT and clng:
You can forcibly convert an expression to a data type.
CINT and clng:
CINT integer-32,768 to 32,767, rounded to the decimal part.
Clng long-2,147,483,648 to 2,147,483,647, rounded to the decimal part.
Overflow refers to the process that exceeds the data processing range.CodeIs the code for processing data to prevent overflow. You can look at it by yourself:
'Check whether it is a short integer
Copy code The Code is as follows: Sub is_int (string)
If Len (ABS (string)> 10 then response. Write "Data overflow": Response. End
If instr (string, "-") <1 then
If CINT (left (string, 4)> 3276 and CINT (right (string, 1)> 7 then response. Write "Data overflow": Response. End
Else
If CINT (left (ABS (string), 4)> 3276 and CINT (right (string, 1)> 8 then response. Write "Data overflow": Response. End
End if
End sub
'Check whether it is a long integerCopy codeThe Code is as follows: Sub is_lng (string)
If Len (ABS (string)> 10 then response. Write "Data overflow": Response. End
If instr (string, "-") <1 then
If clng (left (string, 9)> 214748364 and clng (right (string, 1)> 7 then response. Write "Data overflow": Response. End
Else
If clng (left (ABS (string), 9)> 21478364 and clng (right (string, 1)> 8 then response. Write "Data overflow": Response. End
End if
End sub
The following are some test functions. For more information, see:
First:
I. check whether it is an integer. Copy codeThe Code is as follows: function is_int (a_str)
If not isnumeric (a_str) or Len (STR)> 5 then
Is_int = false
Exit Function
Elseif Len (STR) <5 then
Is_int = true
Exit Function
End if
If CINT (left (a_str, 4)> 3276 then
Is_int = false
Exit Function
Elseif CINT (left (a_str, 4) = 3276 and CINT (right (a_str, 1)> 7 then
Is_int = false
Exit Function
Else
Is_int = true
Exit Function
End if
End Function
2. check whether it is a long integer.
Copy code The Code is as follows: function is_lng (a_str)
If not isnumeric (a_str) or Len (STR)> 10 then
Is_lng = false
Exit Function
Elseif Len (STR) <10 then
Is_lng = true
Exit Function
End if
If clng (left (a_str, 9)> 214748367 then
Is_lng = false
Exit Function
Elseif clng (left (a_str, 9) = 214748367 and clng (right (a_str, 1)> 7 then
Is_lng = false
Exit Function
Else
Is_lng = true
Exit Function
End if
End Function
If we only need to use a number and other items, we can replace them with null values. Below is a regular expression written by the webmaster of the home of scripts, replacing a non-numeric regular expression.Copy codeThe Code is as follows: function replacestr (STR)
Dim re
Set Re = new Regexp
Re. ignorecase = true
Re. Global = true
Re. pattern = "\ D"
STR = Re. Replace (STR ,"")
Replacestr = Str
Set Re = nothing
End Function
The preceding call method is as follows:Copy codeThe Code is as follows: Id = replacestr (ID)
If Len (ID)> 5 then Id = left (ID, 5)
If id <> "" Then Id = clng (ID)
If err. Number <> 0 or ID = "0" then response. Redirect "http://www.jb51.net"
Dim rs
Set rsw.conn.exe cute ("select ID from news where id =" & ID &"")