Connecting Tech Pros Worldwide Help | Site Map

Generating random string

 
LinkBack Thread Tools Search this Thread
  #1  
Old April 16th, 2006, 03:25 AM
John
Guest
 
Posts: n/a
Default Generating random string

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



  #2  
Old April 16th, 2006, 03:55 AM
tina
Guest
 
Posts: n/a
Default Re: Generating random string

answered in post with same subject line, in microsoft.public.access
newsgroup.


"John" <John@nospam.infovis.co.uk> wrote in message
news:BMqdnTCX38CbK9zZRVny3g@pipex.net...[color=blue]
> 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
>
>[/color]


  #3  
Old April 16th, 2006, 05:05 PM
Ira Solomon
Guest
 
Posts: n/a
Default Re: Generating random string

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

On Sun, 16 Apr 2006 04:09:00 +0100, "John" <John@nospam.infovis.co.uk>
wrote:
[color=blue]
>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
>[/color]
  #4  
Old April 16th, 2006, 07:45 PM
John
Guest
 
Posts: n/a
Default Re: Generating random string

Thanks Ira. Works great.

Regards

"Ira Solomon" <isolomon@solomonltd.com> wrote in message
news:git4425qn8229lnria87eskgfmg8vb3q4h@4ax.com...[color=blue]
> 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
>
> On Sun, 16 Apr 2006 04:09:00 +0100, "John" <John@nospam.infovis.co.uk>
> wrote:
>[color=green]
>>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
>>[/color][/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.