473,387 Members | 1,532 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,387 software developers and data experts.

random words

lee123
556 512MB
is there a way to make random words or letters instead of numbers?

lee123
Nov 16 '07 #1
18 3952
debasisdas
8,127 Expert 4TB
generate numbers randomly upto max limit of characters.
Generate the number s randomly and convert to charcter using Chr()
Nov 16 '07 #2
Killer42
8,435 Expert 8TB
is there a way to make random words or letters instead of numbers?
Can you provide a bit more detail about what you want to do? And the version of VB you're using?

For example, by "words" do you mean real words, or random strings of letters, or what?
Nov 16 '07 #3
jamesd0142
469 256MB
Check this .exe file out, if it's what you want, I'll send the code.
Attached Files
File Type: zip Random_Generator.zip (10.3 KB, 359 views)
Nov 16 '07 #4
lee123
556 512MB
Jamesd0142 - well i tried to unzip this but say's there is an error.

hey killer42 yes words, but letters would be nice too. i want to try to build a hang man's game. i didn't know you could have random words or letters for that matter vb6 is the strangest language i had ever tried to learn but if you could give me a hand that would be great!!!

lee123
Nov 17 '07 #5
9815402440
180 100+
Hi.

Add following code in the code window of a form
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.     Public Enum GetRndReturnType
  3.         grString = 0
  4.         grNumber = 1
  5.     End Enum
  6.  
  7. Public Function GetRnd(ReturnType As GetRndReturnType, Optional NoOfChars As Integer = 0, Optional UpperBound As Long = 0, Optional LowerBound As Long = 0, Optional IncludeBounds As Boolean = False) As Variant
  8. '******************************************************************
  9. '*1. If ReturnType = gfString then all arguments except NoOfChars *
  10. '*   are ignored.                                                 *
  11. '*2. If ReturnType = grNumber then following rule applies         *
  12. '*      If NoOfChars are specified then all remaining args are    *
  13. '*      ignored; else number is returned between UpperBound and   *
  14. '*      LowerBound numbers (according to the value of             *
  15. '*      IncludeBounds)                                            *
  16. '******************************************************************
  17.     Dim intChars As Integer
  18.     Dim strRetu As Variant
  19.     If ReturnType = grString Then
  20.         strRetu = Empty
  21.         For intChars = 1 To NoOfChars
  22.             strRetu = strRetu & Chr(Int((90 - 65 + 1) * Rnd + 65))
  23.         Next
  24.     Else
  25.         strRetu = Empty
  26.         If NoOfChars > 0 Then
  27.             For intChars = 1 To NoOfChars
  28.                 strRetu = strRetu & Int((9 - 0 + 1) * Rnd + 0)
  29.             Next
  30.             strRetu = Val(strRetu)
  31.         Else
  32.             If IncludeBounds Then
  33.                 strRetu = Int((UpperBound - LowerBound - 1) * Rnd + LowerBound + 1)
  34.             Else
  35.                 strRetu = Int((UpperBound - LowerBound + 1) * Rnd + LowerBound)
  36.             End If
  37.         End If
  38.     End If
  39.     GetRnd = strRetu
  40. End Function
  41.  
  42. Private Sub Command1_Click()
  43.     MsgBox GetRnd(grString, 5)
  44. End Sub

Regards,
Manpreet Singh Dhillon Hoshiarpur
Nov 18 '07 #6
Killer42
8,435 Expert 8TB
Jamesd0142 - well i tried to unzip this but say's there is an error.

hey killer42 yes words, but letters would be nice too. i want to try to build a hang man's game. i didn't know you could have random words or letters for that matter vb6 is the strangest language i had ever tried to learn but if you could give me a hand that would be great!!!
I managed to unzip it alright.

I think the simplest thing would be to create an array holding all of your known words. Then you just use a random number as the index to pick one out of the array.
Nov 18 '07 #7
daniel aristidou
491 256MB
Check this .exe file out, if it's what you want, I'll send the code.
Note this supposed random generator is not random... the random characters are reproducible.

Would it not be better to use the random number generator in order to completely randomize the characters. Since if used to create passwords it’s unsecure.
Nov 18 '07 #8
lee123
556 512MB
how would you generate several questions with a button? i mean if i had a button that i wanted to have questions i have put in code. and everytime you would click it it would show a different question that was in the code. Example:

question 1: what is...blah blah blah
question 2; who is... blah blah blah

and so forth


lee123
Nov 18 '07 #9
Killer42
8,435 Expert 8TB
how would you generate several questions with a button? ...
Like I said, put them in an array and randomly choose one.
Nov 18 '07 #10
Killer42
8,435 Expert 8TB
Note this supposed random generator is not random... the random characters are reproducible.
Current computer technology isn't actually capable of producing truly random numbers. What they do is use various mathematical techniques to produce "pseudo-random" numbers. As long as this is true, there will probably always be some level of reproducibility.
Nov 18 '07 #11
Robbie
180 100+
show a different question that was in the code. Example:

question 1: what is...blah blah blah
question 2; who is... blah blah blah
If you are not sure how to do it so that 'blah blah blah' can be changed to something else while the program is running (you don't have to change your source code), you could do something like this:

Your array of questions could be set up like this:
Expand|Select|Wrap|Line Numbers
  1. Dim QuestionArray(3) As String
  2. QuestionArray(0)="What is OBJECT?"
  3. QuestionArray(1)="Who is OBJECT?"
  4. QuestionArray(2)="Why is OBJECT?"
  5.  
Then you pick a random one as people have shown, for example:
Expand|Select|Wrap|Line Numbers
  1. Randomize
  2. Dim ChosenQuestion As String
  3. ChosenQuestion = QuestionArray(Rnd*2)
  4.  
Then you simply replace OBJECT with the object you like by doing something like this:
Expand|Select|Wrap|Line Numbers
  1. ChosenQuestion = Replace(QuestionArray,"OBJECT","the dog")
  2.  
For example, ChosenQuestion could now be 'What is the dog?'.
Hope it helps.

Also, Killer, even if we start to 'breed' cyber-organic 'creatures', 'random' numbers will always be made up from facts, even if it is just noise which the computer hears - noise 'sounds' random to us. After all, computers are essentially circuits, which deal with logic and facts. If you try to force yourself to read out random numbers between 1 and 10, it becomes hard, because you soon start to consciously avoid repeating too much, proving that we also use rules when creating 'random' numbers. ;)
Nov 19 '07 #12
lee123
556 512MB
thanks people i'll try all of these

lee123
Nov 19 '07 #13
Killer42
8,435 Expert 8TB
... Also, Killer, even if we start to 'breed' cyber-organic 'creatures', 'random' numbers will always be made up from facts ...
But if you believe the (apparent) nonsense spouted about quantum mechanics, it may some day be possible to produce (or at least detect) truly random events, and hence values.

I don't think we should completely rule out the possibility, just because we can't do it now. After all, who could ever possibly need more than 640KB of RAM? :)
Nov 20 '07 #14
Robbie
180 100+
I haven't read much about quantum mechanics, but I can understand that someday a computer could recognize if a series of numbers was being made using one of today's algorithms. Then we get further off-topic though when we ask what events are truley random? Surely everything happens as a result of something else, so theoretically if you knew enough you could predict anything and change something slightly now to affect something seemingly unrelated in the future?
Nov 20 '07 #15
jamesd0142
469 256MB
so to summarise, theres no possible way to produce truly random secure passwords...?
Nov 20 '07 #16
Robbie
180 100+
so to summarise, theres no possible way to produce truly random secure passwords...?
Well, there are multiple algorithms available which will generate random numbers for you. They become more unpredictable if you mix up different algorithms. For example you could make a random number with algorithm A, multiply it by something random from algorithm B, then divide it by something from algorithm C. Better still, make each character of the password be made by different combinations of algorithms. It gets harder to predict if you do these things.

I certainly wouldn't use VB's random number function to generate secure passwords... but I suggest you look up on ways to create these so-called pseudo-random numbers, which can be converted to characters to make passwords.
Nov 20 '07 #17
Killer42
8,435 Expert 8TB
so to summarise, theres no possible way to produce truly random secure passwords...?
Correct. However, pseudo-random passwords can be made pretty secure.
Nov 21 '07 #18
daniel aristidou
491 256MB
Hi There is absolutely no such thing as a random number even if you ask someone "give me any number out of the top of your head" since the brain makes asumptions using electronical signals and experiences a person has experienced. Thus the number given is based on facts (ie experiences) but using a very complecated formula that no one at the moment can solve.(as far as i know)
Therefore a truly random number in my view can never actually come into existance.

Anyone agree?
Nov 21 '07 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Hans A | last post by:
I have a textfile "textfile.txt" containing a list of words. There is one word on each line. I want to pick two random lines from this textfile, and I have tried to do something like: //Loading...
5
by: Alistair | last post by:
Hello folks... this is my first post in here. I'm new to ASP having done all my previous work in Flash and bog standard HTML. Only been learning for a couple of weeks. anyway...I have been...
23
by: Thomas Mlynarczyk | last post by:
I remember there is a programming language where you can initialize the random number generator, so that it can - if you want - give you the exactly same sequence of random numbers every time you...
11
by: Olaf \El Blanco\ | last post by:
How can i generate random words? ('a'..'z') Is there any function that convert a number to it ascci char? My english is horrible! Here an example: function(65) return 'a'; Thank you!
28
by: Elfour | last post by:
In c++ what is the code to make teh program randomly select a number?
7
by: Jay | last post by:
How would I be able to grab random words from an internet source. I'd like to grab a random word from a comprehensive internet dictionary. What would be the best source and the best way to go...
3
by: duffint | last post by:
Hi there, I have this script that I need some direction in; it's mangled my head a bit. I want to be able to stick links around six random words; these links are then popup ads. I saw kind...
21
by: chico_yallin | last post by:
I just wana make a random id number based on4 digits-for examples?? Thanks in Advance Ch.Yallin
24
by: pereges | last post by:
I need to generate two uniform random numbers between 0 and 1 in C ? How to do it ? I looked into rand function where you need to #define RAND_MAX as 1 but will this rand function give me ...
4
by: philly_bob | last post by:
In the sample program below, I want to send a random method to a class instance. In other words, I don't know which method to send until run-time. How can I send ch, which is my random choice, to...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
0
Oralloy
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 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.