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

Fill Field With Random Integers

How can I fill an empty field (FieldA) in a table with random integers
between 1 and 11?

Thanks!
May 8 '07 #1
2 2617
On Tue, 08 May 2007 23:54:40 GMT, "Steve" <so***@private.emailaddress>
wrote:

There are several ways. Off the top of my head here is one using DAO:
public sub FillWithRandom
dim rs as dao.recordset
randomize
set rs=currentdb.openrecordset("myTable", dbOpenTable)
while not rs.eof
rs.Edit
rs!FieldA = GetRandom(1,11)
rs.Update
rs.MoveNext
wend
rs.close
end sub

private function GetRandom(byval intLow as integer,byval intHigh as
integer) as integer
GetRandom=Int((intHigh - intLow + 1) * Rnd + intLow)
end function

-Tom.
>How can I fill an empty field (FieldA) in a table with random integers
between 1 and 11?

Thanks!
May 9 '07 #2
Thanks, Tom!
"Tom van Stiphout" <no*************@cox.netwrote in message
news:9v********************************@4ax.com...
On Tue, 08 May 2007 23:54:40 GMT, "Steve" <so***@private.emailaddress>
wrote:

There are several ways. Off the top of my head here is one using DAO:
public sub FillWithRandom
dim rs as dao.recordset
randomize
set rs=currentdb.openrecordset("myTable", dbOpenTable)
while not rs.eof
rs.Edit
rs!FieldA = GetRandom(1,11)
rs.Update
rs.MoveNext
wend
rs.close
end sub

private function GetRandom(byval intLow as integer,byval intHigh as
integer) as integer
GetRandom=Int((intHigh - intLow + 1) * Rnd + intLow)
end function

-Tom.
>>How can I fill an empty field (FieldA) in a table with random integers
between 1 and 11?

Thanks!

May 9 '07 #3

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

Similar topics

29
by: Chris Dutrow | last post by:
I searched around on the net for a bit, couldn't find anything though. I would like to find some code for a function where I input A Range Of Integers For example: Function( 1, 100 ); And the...
70
by: Ben Pfaff | last post by:
One issue that comes up fairly often around here is the poor quality of the pseudo-random number generators supplied with many C implementations. As a result, we have to recommend things like...
5
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible...
4
by: Dimos | last post by:
Hello All, I need some help with random number generation. What I need exactly is: To create a few thousand numbers, decimal and integers, between 5 and 90, and then to export them as a...
28
by: Elfour | last post by:
In c++ what is the code to make teh program randomly select a number?
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
1
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I generate a random integer from 1 to N?...
26
by: bilgekhan | last post by:
What is the correct method for generating 2 independent random numbers? They will be compared whether they are equal. What about this method: srand(time(0)); int r1 = rand(); srand(rand());...
10
by: Charles Richmond | last post by:
Is there some parameter I can set via Javascript that will cause the browser to *not* auto-fill forms, regardless of the browser settings??? --...
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
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,...
0
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...
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
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,...

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.