473,383 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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
Apr 16 '06 #1
3 6642
answered in post with same subject line, in microsoft.public.access
newsgroup.
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:BM********************@pipex.net...
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

Apr 16 '06 #2
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" <Jo**@nospam.infovis.co.uk>
wrote:
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

Apr 16 '06 #3
Thanks Ira. Works great.

Regards

"Ira Solomon" <is******@solomonltd.com> wrote in message
news:gi********************************@4ax.com...
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" <Jo**@nospam.infovis.co.uk>
wrote:
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

Apr 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Andreas Lobinger | last post by:
Aloha, i wanted to ask another problem, but as i started to build an example... How to generate (memory and time)-efficient a string containing random characters? I have never worked with...
7
by: eric.gagnon | last post by:
In a program randomly generating 10 000 000 alphanumeric codes of 16 characters in length (Ex.: "ZAZAZAZAZAZAZ156"), what would be an efficient way to ensure that I do not generate duplicates? ...
3
by: Peter Fox | last post by:
The recent thread in generating PINs reminded me: Suppose I want to give someone a random password or ID then this is what I do: (1) Generate a hash, eg. MD5 form something, possibly a random...
16
by: Leon | last post by:
I need a program that generate 5 non-duplicates random number between 1-10 as string values store in an array. Do anybody know of any good books or websites that explain how to generator random...
2
by: Joe | last post by:
Hi, I am building web in ASP.NET using VB.NET to code the pages. I want to generate random passwords for users. I know that password hashing is built right into the .NET Framework. I was...
2
by: Simon Wittber | last post by:
I'm building a web application using sqlalchemy in my db layer. Some of the tables require single integer primary keys which might be exposed in some parts of the web interface. If users can...
2
by: randomcz | last post by:
hi, i need help with generating random numbers; The task is to generate hundreds of random vectors, like 1,3,5,6,7 2,4,5,4,8 ... I used the current time as the random seed, but it turns...
5
by: dav3 | last post by:
Howdy folks, was wondering if anyone could assist me in a better method for generating a alphanumeric sequence of 6 characters/digits. The method I am currently using gives me a random license plate...
6
by: Mike P | last post by:
I am generating 12 random strings and my code works fine when I step through, but when I then let it run without stepping through and populate a listbox with the array I am building, I get the same...
1
by: Krimp | last post by:
I pulled this code from Vbasic.net or generating random passwords. I want to know how I can set up so that each time the page is refreshed a new password is generated without having to fill in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.