Connecting Tech Pros Worldwide Help | Site Map

Generating random string

  #1  
Old April 16th, 2006, 04:25 AM
John
Guest
 
Posts: n/a
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, 04:55 AM
tina
Guest
 
Posts: n/a

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, 06:05 PM
Ira Solomon
Guest
 
Posts: n/a

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, 08:45 PM
John
Guest
 
Posts: n/a

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]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eval code and AppDomains Joe Fallon answers 6 November 21st, 2005 11:26 AM
Calling SOAP Method from VB.NET Cleo answers 0 November 20th, 2005 02:04 PM
Eval code and AppDomains Joe Fallon answers 18 November 19th, 2005 04:26 AM
How to create non-compressible string? Roomates Computer answers 5 July 18th, 2005 12:10 AM