|






|
Question
| From: |
Doherty Family |
| Date: |
Wednesday 07 February 2001 1:03 AM |
| Subject: |
<No subject> |
| Question: |
hey my name's mike and i was just wondering if you could post up like a randomizer project in project form.
My email address is and I just started Visual Studio programming (I'm 13).
Please contact me because I need a lot of help and you look like as though you can help me
|
What type of project do you want me to create for you? I have made a function for random numbers if
that's what you mean:
|
Function Random(Lowerbound As
Long, Upperbound As Long)
Randomize
Random = Int(Rnd * Upperbound) + Lowerbound
End Function |
Comments
| From: |
Sew |
| Date: |
Saturday, August 19, 2006 at 07:28:03 |
| Comments: |
In our LMS(Lottery Management) System we want to select winner,who's record number need to be randomly selected from the database.The
way of selecting a record from the DB not to be the same pattern .It must need to be a random selection. |
| From: |
ßèîgè |
| Date: |
Saturday, September 3, 2005 at 12:54:18 |
| Comments: |
Im looking for a way of genearting random numbers between one and nine such that the same number is not generated more than once. Is there any easy way of doing this or do i have to put the generated numbers in an array and have vb compare them?? |
| From: |
jim |
| Date: |
Saturday, June 4, 2005 at 21:26:47 |
| Comments: |
Need help!
Each time I put randomise, it says : compile error: sub or function not
defined. |
| Reply: |
You need to spell randomise the American way - 'Randomize'.
|
| From: |
Cookie |
| Date: |
Saturday, January 8, 2005 at 20:13:41 |
| Comments: |
I have got the following code to produce a random dice value (1-6), however each time I run my program it gives me the same "random" numbers in the same order.
| random(dice_no) = (Int((6 - 1) * Rnd) + 1) |
Is there anyway to sort this?
|
| Reply: |
The following function will sort numbers into an array, so that each
element has a different number:
Private Sub N_Integers(N As
Integer, rndlist() As Integer)
Randomize
'Randomly sorts N integers and puts results in rndlist
Dim I As Integer, J As
Integer, T As Integer
'Order all elements initially
For I = 1 To N
rndlist(I) = I
Next I
'J is number of integers remaining
For J = N To 2 Step -1
I = Int(Rnd * J) + 1
T = rndlist(J)
rndlist(J) = rndlist(I)
rndlist(I) = T
Next J
End Sub |
For example, if you set the first argument to 6, the elements
of rndlist might be (starting at element 1): 2, 1, 4, 3, 6, 5.
|
| From: |
Emma |
| Date: |
Tuesday, November 2, 2004 at 05:00:35 |
| Comments: |
hi
i am currently having trouble generating random numbers for a maths programme i have to do for a school project. my current coding is
NO1 = (Int(Rnd * 25) + 1)
NO2 = (Int(Rnd * 25) + 1) |
and i have declared my variables and the random numbers are not showing |
| Reply: |
To show the variables, they need to be displayed to the user e.g.:
| MsgBox "Random number 1: " & NO1 &
". Random number 2: " & NO2 |
|
| From: |
Blizzy |
| Date: |
Saturday, July 31, 2004 at 02:58:36 |
| Comments: |
Its
Randomize
text1.text = Int(Rnd * NUMBER) |
| From: |
Bob <UNAVALIABLE> |
| Date: |
Wednesday, December 24, 2003 at 02:36:29 |
| Comments: |
Im making an RPG, i need to generate a random number. It needs to be from 1-26. I need that script to find what creature appears. Please help me! (PS: Im using Visual Basic 6.0) |
| Reply: |
Use the function at the top of this page using numbers 1 and 26:
|
| From: |
Sohail Jamal |
| Date: |
Sunday, November 9, 2003 at 20:05:22 |
| Comments: |
Guyz according to my calculations,the command must be in the following manner :
Randomize
VALUE=Int((HIGHESTNUMBER - LOWESTNUMBER) * Rnd + LOWESTNUMBER)
where VALUE is your variable
HIGHESTNUMBER is the highest number for random generation
LOWESTNUMBER is the lowest number for random generation
|
| From: |
Daniel |
| Date: |
Monday, November 3, 2003 at 12:50:06 |
| Comments: |
just another way it can be done, a MUCH simpler way... though JUST for generating random numbers, nothing else... try:
Private Sub Form_Load()
Randomize
Label1.Caption = Int(Rnd * 10)
End Sub |
10 can be replaced with any number you want, as high or low as you set it!
|
| From: |
Joseph |
| Date: |
Saturday, September 27, 2003 at 11:04:23 |
| Comments: |
Should be like this... i tested it
Function Random(Lowerbound As
Long, Upperbound As Long)
Randomize
Random = Int((Upperbound - Lowerbound) * Rnd + Lowerbound)
End Function |
|
| From: |
Eddie |
| Date: |
Monday, July 14, 2003 at 23:59:57 |
| Comments: |
My program randomly chooses integers then add them
n1+n2=n3. If I wanted the program to toggle from addition to substraction. Let's say! the first time it added the intergers and the next new integers are substracted. Someone suggested using Random(11,13)
I don't understand, do you have a better idea? |
| Reply: |
I think the best way of doing this is to use a Boolean, which when
True the numbers are added and when False, the numbers are
subtracted. E.g.:
Select Case AddNumbers
Case True
n3 = n1 + n2
AddNumbers = False
Case False
n3 = n1 - n2
AddNumbers = True
End Select |
|
Martin Allen 1999 - 2006. Last updated Saturday 16 September 2006 07:28:10 PM +0100.
|