First of all, we need to know
cint range -32,768 to 32,767.
clng range -2,147,483,648 to 2,147,483,647.
Cint and clng meaning:
You can force an expression to a data type
The scope of data processing by cint and clng:
CInteger -32,768 to 32,767, decimal portions are rounded.
CLng Long -2,147,483,648 to 2,147,483,647, the decimal part is rounded.
The so-called overflow refers to exceeding the scope of processing data. The following code is the code to process data to prevent overflow. You can take a look at it yourself:
'Detection of whether it is a short integer
The code copy 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
'Detection of whether it is a long integer
The code copy 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, friends who need it can refer to it:
The first type:
1. Detect whether it is an integer
The code copy is as follows:
functionIs_Int(a_str)
ifnotisnumeric(a_str)orlen(str)>5then
Is_Int=false
exitfunction
elseiflen(str)<5then
Is_Int=true
exitfunction
endif
ifcint(left(a_str,4))>3276then
Is_Int=false
exitfunction
elseifcint(left(a_str,4))=3276andcint(right(a_str,1))>7then
Is_Int=false
exitfunction
else
Is_Int=true
exitfunction
endif