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(st rSeed)
Dim i, nSeed
nSeed = CLng(0)
For i = 1 To Len(strSeed)
nSeed = nSeed Xor ((256 * ((i - 1) Mod 4) * AscB(Mid(strSee d, i, 1))))
Next
Randomize nSeed
End Sub
'----------
Function GeneratePasswor d(nLength)
Dim i, bMadeConsonant, c, nRnd
Const strDoubleConson ants = "bdfglmnpst "
Const strConsonants = "bcdfghklmnpqrs tv"
Const strVocal = "aeiou"
GeneratePasswor d = ""
bMadeConsonant = False
For i = 0 To nLength
nRnd = Rnd
If GeneratePasswor d <"" AND _
(bMadeConsonant <True) AND (nRnd < 0.15) Then
c = Mid(strDoubleCo nsonants, Len(strDoubleCo nsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
bMadeConsonant = True
Else
If (bMadeConsonant <True) And (nRnd < 0.95) Then
c = Mid(strConsonan ts, Len(strConsonan ts) * Rnd + 1, 1)
bMadeConsonant = True
Else
c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
bMadeConsonant = False
End If
End If
GeneratePasswor d = GeneratePasswor d & c
Next
If Len(GeneratePas sword nLength) Then
GeneratePasswor d = Left(GeneratePa ssword, nLength)
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
var_var = GeneratePasswor d(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 3152
scratch that. one of these days I will learn to just think!!
just added 1234567890 in the Const strConsonants = "bcdfghklmnpqrs tv"
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(st rSeed)
Dim i, nSeed
nSeed = CLng(0)
For i = 1 To Len(strSeed)
nSeed = nSeed Xor ((256 * ((i - 1) Mod 4) * AscB(Mid(strSee d, i, 1))))
Next
Randomize nSeed
End Sub
'----------
Function GeneratePasswor d(nLength)
Dim i, bMadeConsonant, c, nRnd
Const strDoubleConson ants = "bdfglmnpst "
Const strConsonants = "bcdfghklmnpqrs tv"
Const strVocal = "aeiou"
GeneratePasswor d = ""
bMadeConsonant = False
For i = 0 To nLength
nRnd = Rnd
If GeneratePasswor d <"" AND _
(bMadeConsonant <True) AND (nRnd < 0.15) Then
c = Mid(strDoubleCo nsonants, Len(strDoubleCo nsonants) * Rnd + 1, 1)
c = c & c
i = i + 1
bMadeConsonant = True
Else
If (bMadeConsonant <True) And (nRnd < 0.95) Then
c = Mid(strConsonan ts, Len(strConsonan ts) * Rnd + 1, 1)
bMadeConsonant = True
Else
c = Mid(strVocal, Len(strVocal) * Rnd + 1, 1)
bMadeConsonant = False
End If
End If
GeneratePasswor d = GeneratePasswor d & c
Next
If Len(GeneratePas sword nLength) Then
GeneratePasswor d = Left(GeneratePa ssword, nLength)
End If
End Function
'----------
StrRandomize CStr(Now) & CStr(Rnd)
var_var = GeneratePasswor d(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 generators, so my solution
at the moment is:
import string
import random
random.seed(14)
|
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 generated and a check made to see whether or not
that key has already been used, something which could generate up to about
10000 keys (or more if the string doesnt have to be too long) would be very
useful.
A combination of letters, numbers, upper and...
|
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 wrapped in duck tape with a few diodes and two wires sticking out.
When attaching the wires to your skin the diodes would light up in a
random configuration. (he later modified this into a skin resistance
|
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 nos(RandomID)stored in the combobox
control. Everytime I enter a new record in F1, the next available
RandomID should be automatically assigned to the new record entry and
displayed in the respective form control(F2). Can anybody guide me...
|
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 appreciate any help!!!
Thank you
| |
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 better way than to fill an array of range 0... RAND_MAX with
pre-computed primes and using the output of rand() to index into it to
extract a random prime.
|
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 this:
def cran_rand(min,max):
if(min>max):
x=max
max=min
min=x
range=round(log(max-min)/log(256))
|
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? Perhaps a string
of 20 digits with a few asterisks thrown in for ease of typing?
for example:
4515-81301-75454-45136-1
|
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:
*************************************************
Function RandomString(size as integer, lowerCase as boolean) as string
Dim builder as StringBuilder = new StringBuilder()
Dim random as Random = new Random()
Dim i as integer
dim ch as char
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |