Visual Basic Code Snippet - Validate Integer
(VB) Visual Basic code snippet to validate given integer. IsInteger function validate integer. Function return TRUE if valid integer found, if not function will return FALSE.
Bookmark:
Visual Basic Code Snippet - Validate Integer
This .Net Visual Basic (VB) code snippet validate integer values. This function uses regular expression to match string pattern to validate integer values.
Public Function IsInteger(ByVal strNumber As String) As Boolean Dim _RegexNotIntPattern As New System.Text.RegularExpressions.Regex("[^0-9-]") Dim _RegexIntPattern As New System.Text.RegularExpressions.Regex("^-[0-9]+$|^[0-9]+$") Return (Not _RegexNotIntPattern.IsMatch(strNumber) AndAlso _RegexIntPattern.IsMatch(strNumber)) End Function
Visual Basic (VB) Keywords Used:
- Regex
- IsMatch
Code Snippet Information:
- Applies To: .Net, VB, Visual Basic, Integer Validation, Regular Expression
- Programming Language : Visual Basic (VB)
External Resources: