five caracter string (1 Viewer)

irade92

Registered User.
Local time
Today, 13:05
Joined
Dec 26, 2010
Messages
229
Hi
how to generate five caracters string of capital letters and number from 1 - 9, for example QQR5T, GH67P...AND SO ON
Thanks !
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:05
Joined
Feb 28, 2001
Messages
27,320
Well, first, how about a little clarification? GH67P includes two characters that aren't capital letters. What are your real requirements?
 

irade92

Registered User.
Local time
Today, 13:05
Joined
Dec 26, 2010
Messages
229
as I wrote mixed = capital letters and numbers from 1-9, excluding zero as number...letters and number can duplicate, no problem
so random letters and random number = string of five caracters
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:05
Joined
Oct 29, 2018
Messages
21,542
Hi. One way to do that might be to store all the letters and numbers in a table and then use a random query to pull five record from it that you can combine together as one. Just a thought...
 

irade92

Registered User.
Local time
Today, 13:05
Joined
Dec 26, 2010
Messages
229
maybe you gave me an idea..let say I make a string of letters and nubmer i.e ABCD..XYW123456789, how many letters are in english and 9 numbers..for example 23 letters and 9 number it is 32.. with for next loop running 5 times , using rnd() function and mid() function, I will take the letter or number from that position...interesting idea..
I just tried this...
dim str as string
DIM x as integer
dim mm as string
mm =""
str = "ABCDEFGHIJKLMNOPQRSTWXY123456789"
FOR x = 1 TO 5
mm = mm & Mid(str;Int(Rnd()*32);1)
x= x + 1

NEXT
 
Last edited:

plog

Banishment Pending
Local time
Today, 06:05
Joined
May 11, 2011
Messages
11,669
What's the purpose, will humans have to read and use this code? If so, you should exclude 0, I, O and 1.
 

oleronesoftwares

Passionate Learner
Local time
Today, 04:05
Joined
Sep 22, 2014
Messages
1,159
hi you can use this code,

a=Chr(Int((90-65+1)*Rnd()+65)) // generates in upper case one random alphabet
b=Chr(Int((90-65+1)*Rnd()+65)) // generates in upper case one random alphabet
c=Int((149-100+1)*Rnd()+10) // generates two random numbers
d=Chr(Int((90-65+1)*Rnd()+65)) // generates in upper case one random alphabet
e=a& " " &b& " " &c& " " &d // concatenates a to d into another field
 

Users who are viewing this thread

Top Bottom