Random Letters

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!
Post Reply
qbfreak2000
Newbie
Posts: 5
Joined: Tue Oct 25, 2005 5:25 pm
Location: U.S.A.
Contact:

Random Letters

Post by qbfreak2000 »

How can I make the program generate random letters instead of just random numbers?
Willi@m C.
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

By making random numbers from 41-90 (Caps) and 61-122 (Lower Case), then use the CHR$() to return the letter value of the numbers.. =)

btw, to get a range(e.g. 3 to 10) of random numbers:

Code: Select all

RandNum = INT(RND * (UPPER - LOWER + 1)) + LOWER
:wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

Try this quick lil function I just whipped up here in the forum editbox:

Code: Select all

FUNCTION RNDLETTER() AS STRING
DIM A AS INTEGER, B AS INTEGER
A = INT(RND(1) * 26)
B = INT(RND(1) * 2)
IF B = 1 THEN
  RNDLETTER = CHR$(97 + A)
ELSE
  RNDLETTER = CHR$(65 + A)
END IF
END FUNCTION
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 »

i made a language program that randomly
picks consanants and vowels if you want it
i can send it to you...

from a beginners programming try....

basically what i did:

was write a vowel file(6)
write a consanant file(20)

then i randomly make a marker(1-20) or (1-6)
go in each file to that spot and
grab the letter...

it makes a 2900 word dictionary ALL 5 letter words
and makes a fake langauge
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

Nekrophidius wrote:Try this quick lil function I just whipped up here in the forum editbox:

Code: Select all

FUNCTION RNDLETTER() AS STRING
DIM A AS INTEGER, B AS INTEGER
A = INT(RND(1) * 26)
B = INT(RND(1) * 2)
IF B = 1 THEN
  RNDLETTER = CHR$(97 + A)
ELSE
  RNDLETTER = CHR$(65 + A)
END IF
END FUNCTION
Very nice, Nek, I like it.
You used a different syntax of RND to get random numbers between 0 and 25 and between 0 and 1. It's different, but it works.
*****
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
User avatar
Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:

Random names

Post by Zim »

I wrote a program in QuickBasic to generate a list of random names and associated random email addresses (as spam bait). You can find the output here: http://www.chibardun.net/~zim/friends.htm

I downloaded a list of the most popular boys/girls/sur- names from the government's census bureau web site and build my program around that. I'll be happy to email the code to any interested party.
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
Post Reply