1. Member
Join Date
Dec 1969
Posts
52

I have just been sitting here for about 30 minuets trying to figure this out on paper before I even atempt to code this.<BR><BR>Using asp I will pick a random number, thus picking that number from a data base yata yata yata....<BR><BR>Trick is this, I want to control the randomness I want certan numbers to have a higher % to get chosen. ie numbers 1-4 number 3 has a 70% chance with the other 1,2,4 only have 10% chance each.<BR><BR>My poor peice of scrap paper and I can not come up with a good logical way of doing this? Any help.

2. Senior Member
Join Date
Dec 1969
Posts
379

This is kind of lame, but here&#039;s one way. Use a select case statement with multiple changes for each value. In other words, say you have 5 records, and you want to retrieve one of the five randomly, but you want record #4 to occur 3x as often as the others... you could do this:<BR><BR>Randomize<BR>Select Case Int((7 - 1 + 1) * Rnd + 1)<BR><BR>Â*Case 1<BR>Â*Â*randomNum = 1<BR>Â*Case 2<BR>Â*Â*randomNum = 2<BR>Â*Case 3<BR>Â*Â*randomNum = 3<BR>Â*Case 4,5,6<BR>Â*Â*randomNum = 4<BR>Â*Case 7<BR>Â*Â*randomNum = 5<BR><BR>End Select

3. Senior Member
Join Date
Dec 1969
Posts
404

declare an array with numbers in approx proportions you want them returned.<BR><BR>use output of rnd to select the index of the array.

4. Senior Member
Join Date
Dec 1969
Posts
404

RANDOMIZE<BR><BR>arr=Array(1,2,3,3,3,3,3,3,3,4)<BR >irnd = CINT(rnd*10) -1<BR>numout = arr(irnd)

5. Senior Member
Join Date
Dec 1969
Posts
404