473,609 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

rnd() not so random?

BSOB
77 New Member
ok, we've all used random, and if we've used it enough we've figured out that it is infact a predictable function. and honestly, i was ok with that. until i realized that the rnd function's quazi-frequency happens to be the width of my screen. which happens to be an issue.
1) does anyone know what im talking about?
2) does anyone know of a good way to make a random number that doesnt have a steady frequency?

if people dont know what im talking about:
make a fullscreen form with borderstyle = 0.

private sub form_click()
dim shade as byte
for y = 0 to screen.height
for x = 0 to screen.width
shade = rnd*256
pset(x,y), rgb(shade,shade ,shade)
next x
doevents
next y
end sub

and clean your glasses, they might just be scratched.
Aug 3 '06 #1
4 3195
danp129
323 Recognized Expert Contributor
not sure what I should look for, I saw what looked like a TV with no signal. Have you tried using Randomize (timer) at the beginning of your code?
Aug 3 '06 #2
Wrycu
9 New Member
Rnd isnt random. Think about it. How could it be? Everything here is coded in. But, as the other person said, if you add Randomize (right before rnd is good), it kills the pattern and the same order the 'random' numbers come up in.
Sep 5 '06 #3
NSF12345
21 New Member
i got told once that the start random number was based on the time and date of the computer (down to the second) so its hard to get the random sequence to run again, but i have often thought the same, how random IS randomize ona computer? and i find that RANDOMIZE at the start of the code (either on load or on click (which ever u want) it tends to garuntee a random number
Sep 6 '06 #4
Wrycu
9 New Member
It cant be random. At least, not truely random. It cannot chose which to pick, it has to be coded in. So, it says...
rnd =
.1343
.453342
.423
.85654
.45634
.1433
.3453
etc
and every time you run it, you get those numbers in that order.
Randomize makes it more random. I dunno how, it probably has some complex thingy that makes it.. more random. or at least, makes it seem random. and as long as it seems random, who cares if it is?
Sep 7 '06 #5

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

Similar topics

6
7281
by: Andrew Banks | last post by:
I'm trying to order a recordset randomly. I've tried the following ORDER BY Rnd(ProdID) - ProdID is my primary key I've read that this will be random but will always return the same random order. I've also read that using the following should resolve this ORDER BY Rnd(Timer()) - this still gives me the same problem I've only got 16 recors in the DB at the moment if this is relevant.
1
1430
by: Leslie | last post by:
I need to get 20 random records from a table based on a condition. The condition isn't a problem. I have tried select top 20 *, rnd(field) from table, but that gets me the top 20 records. I need 20 random records. I would prefer to use SQL only for this if it is possible. Thanks in advance.
0
813
by: Howard Kaikow | last post by:
I can seed Randomize to assure that I get the same sequence, using Rnd each time. I can seed Random to assure that I get the same sequence, using Next, each time. Is there any way to seed Randomize so that Rnd starts with same value as Next? As a test, I used 9660 as the seed to both.
5
2530
by: V Power | last post by:
Hi, I have just been putting together a random number generator to practice with VB .NET. The Rnd command on its own works fine, however as soon as I add = 10 to the string I get a return value of false. If i use the string CStr(Int(Rnd() = 10)) I get a return value of 0. What am I doing wrong - because the debugger seems to think everything is fine.
11
1696
by: bogusexception | last post by:
(or.. "I'm getting too much Tails and not enough Heads") I'm running into a very strange problem with random numbers and long numbers. To demonstrate the problem, I've created a simple test. Consider that a series of coins are to be "flipped" all at once. The result of the combined flip are a series of bits (0 = tails or 1=heads). These bits form a number, and that number can be represented by a type long. OK. Not so bad so far. To...
1
1788
by: Radu | last post by:
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()
2
3498
by: McKirahan | last post by:
Can someone show me the JavaScript equivalent to the following VBScript? Thanks in advance. Randomize For i = 0 to 15 intRnd = Int((16 * Rnd) + 1) Next Perhaps the follwoing is a start?
8
3792
by: zaankanter | last post by:
Hi, This is my problem. A form (startform) is opened, wich is based on a table, called programvariables. This is supposed to be a one-record table, wich will hold some values needed to store user-preferences. The form shows some of these preferences. Now I want on the event of opening this form, to make a random number (integer), and then to store this number in a field in de table(programvariables), wich field I call res3. Then the content...
13
3662
by: Nick | last post by:
Hi there, I'm trying to create a random number via a seed in VB.NET and C++, 2 different applications. I want to be able to use the same seed and get the same random number but unfortunately VB.NET's Random class produces a different set of results than the C++ rnd function. I can't see any reference of rnd being used via API declarations and am just trying to find a way of generating a random number via seed that is identical in...
0
8035
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8534
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8509
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8374
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6969
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5502
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4002
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2502
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
1366
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.