hey gang.
I have a code to create a random string of letters. The number of them can
be whatever I desire.
what i would like to do, is have it both letters and integers. how would i
modify this code to allow that.
'***** make random password ******
Sub StrRandomize(strSeed)
Dim i, nSeed
nSeed = CLng(0)
For i = 1 To Len(strSeed)
nSeed = nSeed Xor ((256 * ((i - 1) Mod 4) * AscB(Mid(strSeed, i, 1))))
Next
Randomize nSeed
End Sub
'----------
Function GeneratePassword(nLength)
Dim i, bMadeConsonant, c, nRnd
Const strDoubleConsonants = "bdfglmnpst"
Const strConsonants = "bcdfghklmnpqrstv"
Const strVocal = "aeiou"
GeneratePassword = ""
bMadeConsonant = False
For i = 0 To nLength
nRnd = Rnd
If GeneratePassword <"" AND _
(bMadeConsonant <True) AND (nRnd < 0.15) Then
c = Mid(strDoubleConsonants, Len(strDoubleConsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
bMadeConsonant = True
Else
If (bMadeConsonant <True) And (nRnd < 0.95) Then
c = Mid(strConsonants, Len(strConsonants) * Rnd + 1, 1)
bMadeConsonant = True
Else
c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
bMadeConsonant = False
End If
End If
GeneratePassword = GeneratePassword & c
Next
If Len(GeneratePassword nLength) Then
GeneratePassword = Left(GeneratePassword, nLength)
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
var_var = GeneratePassword(6)
'**************************************
this gives me 6 letters at random.
for example utjand
i would like it to give say 3 letters and 3 numbers. is this possible with
the code i have?
TIA
Bam 1 3121
scratch that. one of these days I will learn to just think!!
just added 1234567890 in the Const strConsonants = "bcdfghklmnpqrstv"
line, all is well
thanks
"Jeff" <ba*@gig-gamers.comwrote in message
news:46***********************@roadrunner.com...
hey gang.
I have a code to create a random string of letters. The number of them can
be whatever I desire.
what i would like to do, is have it both letters and integers. how would i
modify this code to allow that.
'***** make random password ******
Sub StrRandomize(strSeed)
Dim i, nSeed
nSeed = CLng(0)
For i = 1 To Len(strSeed)
nSeed = nSeed Xor ((256 * ((i - 1) Mod 4) * AscB(Mid(strSeed, i, 1))))
Next
Randomize nSeed
End Sub
'----------
Function GeneratePassword(nLength)
Dim i, bMadeConsonant, c, nRnd
Const strDoubleConsonants = "bdfglmnpst"
Const strConsonants = "bcdfghklmnpqrstv"
Const strVocal = "aeiou"
GeneratePassword = ""
bMadeConsonant = False
For i = 0 To nLength
nRnd = Rnd
If GeneratePassword <"" AND _
(bMadeConsonant <True) AND (nRnd < 0.15) Then
c = Mid(strDoubleConsonants, Len(strDoubleConsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
bMadeConsonant = True
Else
If (bMadeConsonant <True) And (nRnd < 0.95) Then
c = Mid(strConsonants, Len(strConsonants) * Rnd + 1, 1)
bMadeConsonant = True
Else
c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
bMadeConsonant = False
End If
End If
GeneratePassword = GeneratePassword & c
Next
If Len(GeneratePassword nLength) Then
GeneratePassword = Left(GeneratePassword, nLength)
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
var_var = GeneratePassword(6)
'**************************************
this gives me 6 letters at random.
for example utjand
i would like it to give say 3 letters and 3 numbers. is this possible with
the code i have?
TIA
Bam This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
by: Rob Meade |
last post by:
Hi all,
I need to be able to create some license keys for an application. Ideally
these wouldn't be too long in length (ie, easier to remember/type in), but I
would like them to be auto...
|
by: Luke |
last post by:
Hello,
I am the administrator for http://www.nickberg.org - Nick is the man
who was recently beheaded in Iraq.
He was a very ingenious man - once for my birthday had gave me a small
box...
|
by: anita |
last post by:
I had posted this question before, but did not hear from anybody.
Can somebody pls help me out.
I am creating a table with two fields F1, F2 and F2 has about 50,000
randomly generated alphanumeric...
|
by: aahmad76 |
last post by:
Can anyone please help me. I am trying to desing a
program that will create a 10 digit alphanumeric
password. I am new to the Vb.net environment, and
sometimes have no idea what to do.
I...
| |
by: fieldfallow |
last post by:
Hello all,
Is there a function in the standard C library which returns a prime
number which is also pseudo-random?
Assuming there isn't, as it appears from the docs that I have, is there
a...
|
by: Tuvas |
last post by:
Okay, I'm working on devoloping a simple, cryptographically secure
number, from a range of numbers (As one might do for finding large
numbers, to test if they are prime). My function looks like...
|
by: stjulian |
last post by:
I have used
set typ = server.createobject("Scriptlet.TypeLib")
to create a random string of 36 characters. However, is there a way to
create a random string of digits in the length I request?...
|
by: tshad |
last post by:
I have a page that I am getting a username and password as a random number
(2 letters, one number and 4 more letters)
I have 2 functions I call:
*************************************************...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |