Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / April 2006

Tip: Looking for answers? Try searching our database.

Generating random string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 16 Apr 2006 04:09 GMT
Hi

I need to generate a string of six random characters to act as the first
password. Is there an example of how to do this somewhere?

Thanks

Regards
tina - 16 Apr 2006 04:41 GMT
answered in post with same subject line, in microsoft.public.access
newsgroup.

> Hi
>
[quoted text clipped - 4 lines]
>
> Regards
Ira Solomon - 16 Apr 2006 17:56 GMT
This will do it:

Public Function MakePass()
Dim Lets(6) As String
Dim PW As String
Dim i, j, k As Integer
j = 1
Do While j < 6
k = Int((122 * Rnd) + 65)
If (k >= 65 And k < 91) Or (k > 96 And k < 123) Then
   Lets(j) = Chr(k)
   j = j + 1
   End If
Loop
PW = Lets(1) & Lets(2) & Lets(3) & Lets(4) & Lets(5) & Lets(6)
MakePass = UCase(PW)
End Function

This generates the password in upper case.  You can remove UCase to
get upper and lower.  This will repeat letters sometimes.  So you
might get : ABCDEB or CDXXSZ.

If dups are a problm let me know and I can add the code to avoid them.

Good luck
Ira Solomon

>Hi
>
[quoted text clipped - 4 lines]
>
>Regards
John - 16 Apr 2006 20:28 GMT
Thanks Ira. Works great.

Regards

> This will do it:
>
[quoted text clipped - 31 lines]
>>
>>Regards
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.