GENPW Function

 

This slightly trivial function generates a pseudo random 4 character password.

Developed this for an HR application

 

Function GENPW() As String

    Dim varChr As Variant

    Dim strPWD As String

    Dim intLC As Integer

    varChr = VBA.Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")

    strPWD = CStr(Format(Int(Rnd * 10000), "0000"))

    GENPW = ""

    For intLC = 1 To 4

        GENPW = GENPW & varChr(CInt(Mid(strPWD, intLC, 1)))

    Next intLC

End Function

 

Sub testme()

    Dim strPWD As String

    strPWD = GENPW

End Sub