Visual Basic Code Snippet - Validate whole number
(VB) Visual Basic code snippet to validate given whole number. IsWholeNumber function validates positive integers with zero inclusive. Function return TRUE if valid whole number found, if not function will return FALSE.
Bookmark:
Visual Basic Code Snippet - Validate whole number
This .Net Visual Basic (VB) code snippet validate whole number. This function uses regular expression to match string pattern to validate whole number.
Public Function IsWholeNumber(ByVal strNumber As String) As Boolean Dim _RegexNotWholePattern As New System.Text.RegularExpressions.Regex("[^0-9]") Return Not _RegexNotWholePattern.IsMatch(strNumber) End Function
Visual Basic (VB) Keywords Used:
- Regex
- IsMatch
Code Snippet Information:
- Applies To: .Net, VB, Visual Basic, Whole Number Validation, Regular Expression
- Programming Language : Visual Basic (VB)
External Resources: