Skip to content

Instantly share code, notes, and snippets.

@bervukas
Last active May 27, 2019 23:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bervukas/be5520c22fd8aa18d0344f05aadb92e7 to your computer and use it in GitHub Desktop.
Tutorial: Excel Unit Testing with VBA
Option Explicit
''
' Validate the password length so that it's between 8-16 characters long
'
' Returns:
'
' TRUE - Password matches the lenght requirement
' FALSE - Password doesn't match the length requirement
Function ValidatePasswordLength(password As String) As Boolean
Dim success As Boolean: success = False
' Validate the password is of correct length (between 8-16 characters)
Dim length As Long: length = Len(password)
If (length >= 8 And length <= 16) Then
success = True
End If
ValidatePasswordLength = success
End Function
@IvenBach
Copy link

Thanks for writing about Rubberduck's unit test feature. You have a typo on line 8 the h and t in length are transposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment