Advertisement
UsernameHere1

Untitled

Feb 21st, 2024
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.56 KB | None | 0 0
  1. Public Class clsValidation 'validation class
  2.     Public Function presenceCheck(ByVal validationItem As String) 'create a public method for presence checks and pass in the value of a variable
  3.         Dim result As Boolean = True 'the result of the check
  4.         If validationItem = "" Then 'If there is no text return false
  5.             result = False 'check not met
  6.         End If
  7.         Return result 'return the result
  8.     End Function
  9.  
  10.     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
  11.         Dim result As Boolean = False 'the result of the check
  12.         If validationItem.Length <= maxLength And validationItem.Length >= minLength Then 'if the string is between the min and max amount of characters
  13.             result = True 'check met
  14.         End If
  15.         Return result 'return the result
  16.     End Function
  17.  
  18.     Public Function characterCheck(ByVal validationItem As String, ByVal bannedCharacter As String) 'Doesnt allow a certain character to be added'
  19.         Dim result As Boolean = True 'the result of the check
  20.         Dim counter As Integer 'the index for current character to look at
  21.         For counter = 0 To validationItem.Length - 1 'check every character
  22.             If validationItem(counter) = bannedCharacter Then 'if the character is banned
  23.                 result = False 'check not met
  24.             End If
  25.         Next
  26.         Return result 'return the result
  27.     End Function
  28.  
  29. End Class
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement