is there a way to make random words or letters instead of numbers?
lee123
18 3952
generate numbers randomly upto max limit of characters.
Generate the number s randomly and convert to charcter using Chr()
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?
Check this .exe file out, if it's what you want, I'll send the code.
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
Hi.
Add following code in the code window of a form -
Option Explicit
-
Public Enum GetRndReturnType
-
grString = 0
-
grNumber = 1
-
End Enum
-
-
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
-
'******************************************************************
-
'*1. If ReturnType = gfString then all arguments except NoOfChars *
-
'* are ignored. *
-
'*2. If ReturnType = grNumber then following rule applies *
-
'* If NoOfChars are specified then all remaining args are *
-
'* ignored; else number is returned between UpperBound and *
-
'* LowerBound numbers (according to the value of *
-
'* IncludeBounds) *
-
'******************************************************************
-
Dim intChars As Integer
-
Dim strRetu As Variant
-
If ReturnType = grString Then
-
strRetu = Empty
-
For intChars = 1 To NoOfChars
-
strRetu = strRetu & Chr(Int((90 - 65 + 1) * Rnd + 65))
-
Next
-
Else
-
strRetu = Empty
-
If NoOfChars > 0 Then
-
For intChars = 1 To NoOfChars
-
strRetu = strRetu & Int((9 - 0 + 1) * Rnd + 0)
-
Next
-
strRetu = Val(strRetu)
-
Else
-
If IncludeBounds Then
-
strRetu = Int((UpperBound - LowerBound - 1) * Rnd + LowerBound + 1)
-
Else
-
strRetu = Int((UpperBound - LowerBound + 1) * Rnd + LowerBound)
-
End If
-
End If
-
End If
-
GetRnd = strRetu
-
End Function
-
-
Private Sub Command1_Click()
-
MsgBox GetRnd(grString, 5)
-
End Sub
Regards,
Manpreet Singh Dhillon Hoshiarpur
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.
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.
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
how would you generate several questions with a button? ...
Like I said, put them in an array and randomly choose one.
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.
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: -
Dim QuestionArray(3) As String
-
QuestionArray(0)="What is OBJECT?"
-
QuestionArray(1)="Who is OBJECT?"
-
QuestionArray(2)="Why is OBJECT?"
-
Then you pick a random one as people have shown, for example: -
Randomize
-
Dim ChosenQuestion As String
-
ChosenQuestion = QuestionArray(Rnd*2)
-
Then you simply replace OBJECT with the object you like by doing something like this: -
ChosenQuestion = Replace(QuestionArray,"OBJECT","the dog")
-
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. ;)
thanks people i'll try all of these
lee123
... 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? :)
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?
so to summarise, theres no possible way to produce truly random secure passwords...?
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.
so to summarise, theres no possible way to produce truly random secure passwords...?
Correct. However, pseudo-random passwords can be made pretty secure.
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?
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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!
|
by: Elfour |
last post by:
In c++ what is the code to make teh program randomly select a number?
|
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...
|
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...
|
by: chico_yallin |
last post by:
I just wana make a random id number based on4 digits-for examples??
Thanks in Advance
Ch.Yallin
|
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 ...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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,...
| |