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