Returns a random password that is easier to remember, such as BONES or LAMOT.
You simply call GenerateMemorablePassword, passing the length of the password you require.
It passes back a consonant-vowel-consonant-vowel combination,
meaning the returned phrase is much easier to remember than most automatically generated passwords, such as YPSWW94441.
Usage: MsgBox GenerateMemorablePassword(5)

Public Function GenerateMemorablePassword(Length As Integer) As String
 Dim blnOnVowel As Boolean
 Dim strTempLetter As String
 Dim strPassword As String
 For i = 1 To Length
  If blnOnVowel = False Then
   strTempLetter = Choose(GetRandomNumber(1, 17), _
    "B", "D", "F", "G", "H", "J", "K", "L", "M", _
    "N", "P", "R", "S", "T", "V", "W", "Y") ' Choose a 'nice' consonant - no C, X, Z, or Q, thanks!
   strPassword = strPassword & strTempLetter ' Append it to the password string
   blnOnVowel = True ' Switch to vowel mode
   strTempLetter = Choose(GetRandomNumber(1, 5), "A", "E", "I", "O", "U") ' Choose a vowel
   strPassword = strPassword & strTempLetter ' Append it to the password string
   blnOnVowel = False ' Switch back again, ready for next loop round
  End If
 Next i
 GenerateMemorablePassword = strPassword ' Set function to the password string
End Function
Public Function GetRandomNumber(Upper As Integer, Lower As Integer) As Integer
 Randomize ' Returns a random number within the lower and upper limits
 GetRandomNumber = Int((Upper - Lower + 1) * Rnd + Lower)
End Function


Views 2637 Downloads 795

Protection VBA