Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class clsValidation 'validation class
- Public Function presenceCheck(ByVal validationItem As String) 'create a public method for presence checks and pass in the value of a variable
- Dim result As Boolean = True 'the result of the check
- If validationItem = "" Then 'If there is no text return false
- result = False 'check not met
- End If
- Return result 'return the result
- End Function
- Public Function lengthCheck(ByVal validationItem As String, ByVal maxLength As Integer, ByVal minLength As Integer) 'checks the string is between a certain minimum and maximum amount of characters
- Dim result As Boolean = False 'the result of the check
- If validationItem.Length <= maxLength And validationItem.Length >= minLength Then 'if the string is between the min and max amount of characters
- result = True 'check met
- End If
- Return result 'return the result
- End Function
- Public Function characterCheck(ByVal validationItem As String, ByVal bannedCharacter As String) 'Doesnt allow a certain character to be added'
- Dim result As Boolean = True 'the result of the check
- Dim counter As Integer 'the index for current character to look at
- For counter = 0 To validationItem.Length - 1 'check every character
- If validationItem(counter) = bannedCharacter Then 'if the character is banned
- result = False 'check not met
- End If
- Next
- Return result 'return the result
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement