473,407 Members | 2,306 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,407 software developers and data experts.

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()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(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 1776
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.comwrote in message
news:11*********************@y5g2000hsa.googlegrou ps.com...
As simple-to-remember-but-unique confirmation numbers, I need to
generate six random characters (ASCII 65 to 90, inclusive):

Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65))))
Randomize()
objStringBuilder.Append(Chr(CInt(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
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...
6
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...
10
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
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
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...
1
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...
3
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...
0
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...
11
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...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.