Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Text.RegularExpressions
- Public Class Validation
- 'class is used in order to call specific validation check functions anywhere in the code
- Public Function lengthCheck(ByVal ValidationInput As String, ByVal CharLength As Integer, ByVal ErrorPrompt As String, ByVal parameters As String) As Boolean
- If parameters = "Max" Then 'if the character limit is the maximum length that can be input
- If ValidationInput.Length <= CharLength Then 'if the input string's length is less than the maximum length of characters then:
- Return True 'return true if the length is shorter or equal to the maximum length of characters
- Else
- 'If the input string has more charaters than the maximum, then a message box will be shown:
- MsgBox(ErrorPrompt & " - Your input has too many characters and exceeds the limit, please correct your input to be shorter than(" & CharLength & ") characters.")
- Return False 'Return false to show that there was an error
- End If
- ElseIf parameters = "Min" Then 'if the character limit is the minimum length that can be input
- If ValidationInput.Length >= CharLength Then 'if the input string's length is more than the minimum length of characters then:
- Return True 'return true if the length is bigger or equal to the minimum length of characters
- Else
- 'If the input string has less charaters than the minimum, then a message box will be shown:
- MsgBox(ErrorPrompt & " - Your input has too little characters and isn't long enough, please correct your input to be longer than(" & CharLength & ") characters.")
- Return False 'Return false to show that there was an error
- End If
- ElseIf parameters = "Limit" Then 'if the character limit the only length that can be input
- If ValidationInput.Length = CharLength Then 'if the input string's length the same as the set parameter then:
- Return True 'return true if the length matches
- Else
- 'If the input string has more or less charaters than the paramter, then a message box will be shown:
- MsgBox(ErrorPrompt & " - Your input has doesn't have the correct number of characters, please correct your input to be (" & CharLength & ") characters.")
- Return False 'Return false to show that there was an error
- End If
- Else
- MsgBox("No length parameters specified")
- Return False
- End If
- End Function
- Public Function presenceCheck(ByVal validationInput As String) As Boolean
- 'presence check checks if there is any data input into the textboxes
- If validationInput = "" Then 'checks if the input has no data stored in it
- Return False 'if there isn't any data, the function will return a false output to show that it failed the presence check
- Else
- Return True 'if there is data, the function will return a true output to show that it passed the presence check
- End If
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement