473,548 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Radomize and RND not really random... Weird ?

As simple-to-remember-but-unique confirmation numbers, I need to
generate six random characters (ASCII 65 to 90, inclusive):

Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))

The strange thing is the results are not really random, and they
follow some kind of strange patterns...

I obtain strings like (Pattern 1 = Repeat Sequences):
WUPYUP, ECVGCW, QOJSOJ, and similar.

One other pattern, (Pattern2 = Letters in Vicinity), which shows up
extremely frequently seems to be in results like NLFPKG, IGBLGC,
KICMHD, etc. Note that:

Letter1 is "NEAR" Letter4,
Letter2 is "NEAR" Letter4,
Letter3 is "NEAR" Letter5

Actually, Pattern1 is a particular case of Pattern2...

Hmmmmmm... I am forgetting something ?

Thanks a lot.
Alex.

May 4 '07 #1
1 1785
You may want to stop using the legacy VB 6.0 Randomize() and Rnd() functions
and use the .NET Random class instead:

http://msdn2.microsoft.com/en-us/lib...em.random.aspx
"Radu" <cu************ *@yahoo.comwrot e in message
news:11******** *************@y 5g2000hsa.googl egroups.com...
As simple-to-remember-but-unique confirmation numbers, I need to
generate six random characters (ASCII 65 to 90, inclusive):

Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilde r.Append(Chr(CI nt(Int((25 * Rnd()) + 65))))

The strange thing is the results are not really random, and they
follow some kind of strange patterns...

I obtain strings like (Pattern 1 = Repeat Sequences):
WUPYUP, ECVGCW, QOJSOJ, and similar.

One other pattern, (Pattern2 = Letters in Vicinity), which shows up
extremely frequently seems to be in results like NLFPKG, IGBLGC,
KICMHD, etc. Note that:

Letter1 is "NEAR" Letter4,
Letter2 is "NEAR" Letter4,
Letter3 is "NEAR" Letter5

Actually, Pattern1 is a particular case of Pattern2...

Hmmmmmm... I am forgetting something ?

Thanks a lot.
Alex.

May 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3918
by: ,hj | last post by:
From: ",hj" <webmaster@mail.com> Subject: Losing random characters in HTML email Date: 28 November 2003 17:21 I've narrowed down my code as much as I can so that I can show you this bug. The reason the a's are there and not removed is because if I remove them the problem doesn't show itself. It seems that there is a pattern and the nth...
6
1560
by: jon morgan | last post by:
Hi, I get random errors raised when compiling a multi-project application. For example the compiler will claim that a class has no constructor when it does. If I replace the first line of the constructor with the same code ( or just re-load VS) and then recompile things are OK for a while but then the spurious error comes back. The same...
10
3606
by: Johannes Veerkamp | last post by:
hi there, i'm a newbie in c and i'd like to write a programm which generates random numbers from 1 to 10 (integers). can anybody help me out with the correct code? thanx
20
4416
by: William Stacey [MVP] | last post by:
int list = {1,2,3,4,5,6}; Function to randomize the list? Cheers! -- William Stacey, MVP
1
1913
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at http://oldmill.uchicago.edu/~wilder/Code/random/. Firstly, I got the notorious "fatal error C1010: unexpected end of file while looking for precompiled header directive" error when...
1
1909
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at http://oldmill.uchicago.edu/~wilder/Code/random/. Firstly, I got the notorious "fatal error C1010: unexpected end of file while looking for precompiled header directive" error when...
3
2489
by: td0g03 | last post by:
Like the titles says I'm suppose to generate a random number then divide that by a number inputed by a user. The random number can range from 2-8. I tried to do the code, but I get some weird result here is the result Please enter a number: 18 a. number 18.00 b. the random number 6 00-1.#J <<...
0
1818
by: P Pulkkinen | last post by:
Dear all, sorry, i know this code is far little too long to debug here, but there is really annoying logical error. If someone debugs this, I really offer warm virtual handshake. What this code SHOULD do: - read new (=updated) licensetext from file $license_path then - read and modify recursively all files from $current_dir, replacing...
11
1374
by: ssecorp | last post by:
I am never redefining the or reassigning the list when using validate but since it spits the modified list back out that somehow means that the modified list is part of the environment and not the old one. i thought what happend inside a function stays inside a function meaning what comes out is independent of what comes in. Meaning if I want...
0
7518
marktang
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...
0
7711
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, 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. ...
0
7954
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5367
isladogs
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...
0
5085
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3497
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...
1
1932
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
0
755
bsmnconsultancy
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...

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.