ASP 三层架构 Convert类实现代码(2)

复制代码 代码如下:

Class Con_Convert
' ******global message
private i,j,value0,value1,value2
Private Sub Class_Initialize
End Sub
Private Sub Class_Terminate
End Sub
' ==============================================================================
' Check Type, Return ture/false
' ==============================================================================
Public Function IsStr(ByVal Value)
IsStr=true
End Function
' ****** check string if is Integer
Public Function IsInteger(ByVal Value)
if Trim(Value)="" or IsNull(Value) or IsEmpty(Value) then
IsInteger=false
else
IsInteger = True
value0=Trim(Value)
For i = 1 To len(value0)
If Asc(Mid(value0, i, 1))>= Asc("0") and Asc(Mid(value0, i, 1)) <= Asc("9") Then
Else
if Asc(Mid(value0, i, 1))= Asc("-") and i=1 then
else
IsInteger = false
Exit For
end if
End If
Next
end if
End Function
' ****** check if Value is in range of integer
' Only use in this class
' Value :
' vBound : max
Private Function IsOverflowInteger(ByVal Value,ByVal vBound)
if IsInteger(Value) and IsInteger(vBound) then
IsOverflowInteger=false
value0=trim(value)
value1=trim(vBound)
if IsOverflowInteger=false then
'delete 0 from left
do while ( left(value0,1)="0" or left(value0,1)="-" )
value0=right(value0,len(value0)-1)
loop
do while ( left(value1,1)="0" or left(value1,1)="-" )
value1=right(value1,len(value1)-1)
loop
if len(value0)=len(value1) then
for i=1 to len(value0)
if Asc(mid(value0,i,1)) > Asc(mid(value1,i,1)) or Asc(mid(value0,i,1)) > Asc("9") or Asc(mid(value0,i,1)) < Asc("0") then
IsOverflowInteger=true
exit for
end if
next
else
if len(value0)>len(value1) then
IsOverflowInteger=true
end if
end if
end if
else
IsOverflowInteger=true
end if
End Function
Public Function IsInt(ByVal Value)
IsInt=true
if left(trim(value),1)="-" then
if IsOverflowInteger(trim(value),"-32768") then
IsInt=false
end if
else
if IsOverflowInteger(trim(value),"32767") then
IsInt=false
end if
end if
end function
Public Function IsLng(ByVal Value)
IsLng=true
if left(trim(value),1)="-" then
if IsOverflowInteger(trim(value),"-2147483648") then
IsLng=false
end if
else
if IsOverflowInteger(trim(value),"2147483647") then
IsLng=false
end if
end if
End Function
' **************************************
' Decimal
' **************************************
' ****** check string if is Decimal
Private Function IsDecimal(ByVal Value)
dim intDecimalCount
intDecimalCount=0
if Trim(Value)="" or IsNull(Value) or IsEmpty(Value) then
IsDecimal=false
else
IsDecimal = True
value0=Trim(Value)
For i = 1 To len(value0)
If Asc(Mid(value0, i, 1))>= Asc("0") and Asc(Mid(value0, i, 1)) <= Asc("9") Then

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2112.html