A function for ASP to detect integers and long integers

Source: Internet
Author: User
Tags exit end functions integer
Often see CInt and clng overflow error, if there is a detection function will not be the problem, the following two functions are requested by a friend to write, look at it

Often see CInt and clng overflow error, if there is a detection function will not be the problem, the following two functions are requested by a friend to write, look at it

' Detects whether a string is an integer
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 (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

' Detect if it is a long integer
function Is_lng (A_STR)
If not IsNumeric (A_STR) or Len (str) > Then
IS_LNG = False
Exit function
ElseIf len (str) < Then
IS_LNG = True
Exit function
End If
If CLng (left (A_STR, 9)) > 214748367 Then
IS_LNG = False
Exit function
ElseIf CLng (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



Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.